| Author: Lalji 30 Oct 2009 | Member Level: Diamond | Rating:  Points: 2 |
you can visit this article
http://www.dotnetspider.com/resources/3138-How-make-Numeric-Textbox-using-JavaScript-at.aspx
|
| Author: Nikhil Gaur 30 Oct 2009 | Member Level: Diamond | Rating:  Points: 2 |
look at the following link
http://niksgaur.blogspot.com/2009/07/enter-only-digits-in-textbox.html
Join this campus group http://www.dotnetspider.com/sites/637/-ecb-aspdotnet.aspx
Thanks & Regards NIks My Software and Web Development Experience
|
| Author: Gaurav Arora 30 Oct 2009 | Member Level: Diamond | Rating:    Points: 6 |
Nazia Suman,
I prefer you to use RegularExpression.
Check this DNS link:
http://www.dotnetspider.com/forum/227927-RegEx.aspx
If you want to use it through Javascript then you can also use RegExpression, also there is another way touse KeyCode of the javascript
refer to this link which tell you for all KeyCode and it handling: http://asquare.net/javascript/tests/KeyCode.html
Thanks & regards, Gaurav Arora - Sr. Editor Me in My Own Style
|
| Author: Anil Kumar Pandey 30 Oct 2009 | Member Level: Diamond | Rating:    Points: 6 |
try this function
function IsNumeric(strString) // check for valid numeric strings { var strValidChars = "0123456789.-"; var strChar; var blnResult = true;
if (strString.length == 0) return false;
// test strString consists of valid characters listed above for (i = 0; i < strString.length && blnResult == true; i++) { strChar = strString.charAt(i); if (strValidChars.indexOf(strChar) == -1) { blnResult = false; } } return blnResult; }
// -->
Thanks & Regards Anil Kumar Pandey
|
| Author: vineeth kumar 30 Oct 2009 | Member Level: Silver | Rating:  Points: 2 |
hi .... just tyr this it will work for ur requirment
function isNumeric(elem, helperMsg){ var numericExpression = /^[0-9]+$/; if(elem.value.match(numericExpression)){ return true; }else{ alert(helperMsg); elem.focus(); return false; } } </script> <form> Numbers Only: <input type='text' id='numbers'/> <input type='button' onclick="isNumeric(document.getElementById('numbers'), ' Only Numbers are allowed Please')" value='Check Field' /> </form>
|
| Author: Deepika Haridas 30 Oct 2009 | Member Level: Diamond | Rating:  Points: 2 |
Hello,
You can write this in keypress event
int x = e.KeyChar; if (x >= 48 && x <= 57) { e.Handled = false; } else { e.Handled = true; txtpages.Text = ""; }
Thanks & Regards, Deepika Editor
If U want to shine like a SUN..First U have to burn like the SUN!! Need a Guide? Join my mentor program..
|