Refer below code.
<asp:TextBox runat="server" ID="txtDigits" onchange="Validate(this.value)"
onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;" />
<script type="text/javascript">
function Validate(value) {
if (value.length != 11) {
alert("11 digits required.");
}
}
var specialKeys = new Array();
specialKeys.push(8);
function IsNumeric(e) {
var keyCode = e.which ? e.which : e.keyCode
var ret = ((keyCode >= 48 && keyCode <= 57) || specialKeys.indexOf(keyCode) != -1);
return ret;
}
</script>