Hi,
In order to restrict user to enter numeric or decimalised value in the
textbox. We have comparevalidator in ASP.NET. But If u want not to enter any
non-numeric value then I have code to validate enter data in client side.
I am attaching the file that contains the code to enter only numeric data.
Kindly give me feedback about this code, it work or not
Krishan Kant Chamoli
Chandigarh
Send instant messages to your online friends http://uk.messenger.yahoo.com
----------
####################################### Put This code in HTML Page
###########################################
<script language="JavaScript">
var m_allow=true;
function checkKeycode(e) {
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
//alert("keycode: " + keycode);
if ((keycode>=48 && keycode<=57) || (keycode == 190) ||
(keycode == 8))
{
////////////////// Check of existance of decimal
number. //////////////////
if (keycode == 190)
{
if (m_allow == true)
{
var
strDec=document.Form1.TextBox1.value;
if (strDec.indexOf(".") != -1)
{
event.returnValue=false;
}
}
else
{
event.returnValue=false;
}
}
////////////////// Checking condition ends here
//////////////////
}
else
{
event.returnValue=false;
}
}
</script>
############################### On Page Load #################################
TextBox1.Attributes.Add("onkeydown","checkKeycode(this)");
[Non-text portions of this message have been removed]
------------------------ Yahoo! Groups Sponsor --------------------~-->
<font face=arial size=-1><a
href="http://us.ard.yahoo.com/SIG=12hbitpem/M=362131.6882499.7825260.1510227/D=groups/S=1705006764:TM/Y=YAHOO/EXP=1123074319/A=2889191/R=0/SIG=10r90krvo/*http://www.thebeehive.org
">Get Bzzzy! (real tools to help you find a job) Welcome to the Sweet Life
- brought to you by One Economy</a>.</font>
--------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/