Grab the RSS feed

Text box allow only the numbers by using Jquery

Today I need a coding for text box only allow the numbers. I got the script from the net. Here I am going to present for users.

The coding shows below…

HTML coding..

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
< html xmlns="">
< head>
< meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
< title>Untitled Document</title>
< script type="text/javascript" src="jquery/jquery.js"></script>
< script type="text/javascript" src="jquery/jqueryvalid.js"></script>
< body>
< input type="text" name="quantity" id="quantity" /> 

Before going to run the code please note I include the jquery.js. This is the file you can get from .before the jquery/jquery.js here jqurey is the folder name you can write as username/jquery.js or else what you wish..

Then in next I include another javascript file named jqueryvalid.js.Here you need to write the jqueryvalid.js in the jquery folder.

jqueryvalid.js ……

$("#quantity").keypress(function (e){
if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57))
//display error message
$("#errmsg").html("Digits Only").show().fadeOut("slow"); 
return false;



Whenever the key pressed within the textbox it is checked ASCII character for whwther is it number or alphabet. If alphabet it wont be allowed to enter.

It is really useful for validation…


    Real Time Web Analytics