c# - how disallow only (a-zA-Z) in asp.net? -


how disallow (a-za-z) in asp.net(c#) in textbox ?

you can check key code when user types in text box. example:

function checknumber(e, control) {     isie = document.all ? 1 : 0     keyentry = !isie ? e.which : event.keycode;     if ((keyentry > '47') && (keyentry < '58'))         return true;     else if (keyentry == '8')         return true;     else if (keyentry == '46')         return false;     else         return false; } 

and call function on key press:

onkeypress="return checknumber(event, this);" 

this code allows digits in textbox. can change required.


Comments