Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post May 09, 2012 09:21 AM by animesh.andy
Member
119 Points
243 Posts
May 09, 2012 08:45 AM|LINK
I have created dynamic textbox now I need to validate it to check for only numbers how to do it
Contributor
2270 Points
659 Posts
May 09, 2012 09:07 AM|LINK
hi
i hope it will help you
http://csharpektroncmssql.blogspot.com/2011/11/allow-only-numeric-using-java-script.html
http://csharpektroncmssql.blogspot.in/2012/04/allow-only-numeric-or-characters-to.html
May 09, 2012 09:21 AM|LINK
I solved it Here is the solution
<script language="javascript" type="text/javascript"> function onlyNumbers(evt) { evt = (evt) ? evt : window.event; var charCode = (evt.which) ? evt.which : evt.keyCode; if (charCode > 31 && (charCode < 48 || charCode > 57)) { status = "This field accepts numbers only."; alert("This field accepts numbers only."); return false; } status = ""; return true; } </script>
tb.Attributes.Add("onkeypress", "return onlyNumbers(event);");
where tb is the dynamic textbox control
animesh.andy
Member
119 Points
243 Posts
Dynamic textbox validation
May 09, 2012 08:45 AM|LINK
I have created dynamic textbox now I need to validate it to check for only numbers how to do it
bhaskar.mule
Contributor
2270 Points
659 Posts
Re: Dynamic textbox validation
May 09, 2012 09:07 AM|LINK
hi
i hope it will help you
http://csharpektroncmssql.blogspot.com/2011/11/allow-only-numeric-using-java-script.html
http://csharpektroncmssql.blogspot.in/2012/04/allow-only-numeric-or-characters-to.html
Site:Rare technical solutions
animesh.andy
Member
119 Points
243 Posts
Re: Dynamic textbox validation
May 09, 2012 09:21 AM|LINK
I solved it Here is the solution
<script language="javascript" type="text/javascript">
function onlyNumbers(evt) {
evt = (evt) ? evt : window.event;
var charCode = (evt.which) ? evt.which : evt.keyCode;
if (charCode > 31 && (charCode < 48 || charCode > 57)) {
status = "This field accepts numbers only.";
alert("This field accepts numbers only.");
return false;
}
status = "";
return true;
}
</script>
tb.Attributes.Add("onkeypress", "return onlyNumbers(event);");
where tb is the dynamic textbox control