Login    Forum    Search    FAQ   Blog

Board index » Client-Side Development » Javascript




 Page 1 of 1 [ 3 posts ] 



Author Message
 Post subject: How to allow the user to enter numeric digit
 Post Posted: Tue Aug 04, 2009 7:59 pm 
Offline

Joined: Sat Feb 21, 2009 3:08 pm
Posts: 42
Hi

how to allow the user to enter only numeric digits like 500.00
Please post any sample code.............


Top 
 Post subject: Re: How to allow the user to enter numeric digit
 Post Posted: Tue Aug 04, 2009 8:00 pm 
Offline

Joined: Sat Feb 21, 2009 3:06 pm
Posts: 33
function CheckNumber(controlname)
{

if ((event.keyCode < 48 || event.keyCode > 57 ) && (event.keyCode != 46))
{
event.keyCode = null;
}


}

//call this function in textbox onkeypress event


Top 
 Post subject: Re: How to allow the user to enter numeric digit
 Post Posted: Tue Aug 04, 2009 8:00 pm 
Offline

Joined: Sat Feb 21, 2009 11:06 am
Posts: 1794
Hi,

function valNumericdot(evt)
{

var charCode;
charCode = (evt.which) ? evt.which : event.keyCode;
if (charCode >= 48 && charCode <= 57 || charCode == 46)
{
return true;
}
else
{
return false;
}
}

call this function in the onkeypress event of textbox as follows:

<asp:textbox onkeypress="return valNumericdot(event); " runat="server"></asp:textbox>

Please rate this post, if it is useful for you.

Thanks & Regards


Top 
Display posts from previous:  Sort by  
 
 Page 1 of 1 [ 3 posts ] 




Board index » Client-Side Development » Javascript


Who is online

Users browsing this forum: No registered users and 1 guest

 
 

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron