Restrict the Textbox to enter only Numbers Using Javascript
Normally we get this type of requirement to accept only numbers in a text box.Suppose we have a Credit Card Number entry where we want to validate the key-press is number or not.Here i have simplified the way to enter only numbers in the text-box. Here i have written some logic to enter only numbers in textbox using javascript. < script type = " text/javascript " > function isNumberKey ( evt ) { var charCode = ( evt . which ) ? evt . which : event . keyCode if ( charCode > 31 && ( charCode < 48 || charCode > 57 ) ) return false ; return true ; } < script > Now we can call this fu nction in the events like keypress,keydown and keyup to validate the value is number or not. Happy Coding :-)
very nice article and straight to the point .
ReplyDeletei would just like to have an example that uses List and returns the data as JSON to the client.
it would be nice to have a WCF or usual WEbservice for this implementation.
Thanks for sharing this nice code
Maher
You are welcome Maher. Bookmark this link to get updates :-)
ReplyDelete