
Hi Sir
I have following field in my html form :
<div>Age<input type="text" name="quantity" id="quantity" /></div>
I want to implement two things :
1 if the letter is not digit then display error and don't type anything
2 Age must be between 18 & 35 and it will show error when it is not in between age range.
Please provide code.

You can implement these two things using ASCII code & parseint method. Code is provided below :
//called when key is pressed in textbox
$("#quantity").keypress(function (e)
{
$("#errmsg").hide();
//if the letter is not digit then display error and don't type anything
if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57))
{
//display error message
$("#errmsg").html(" Digits Only").show();
return false;
}
});
$('#quantity').blur(function(a) {
if((parseInt($("#quantity").val(), 10)<18))
{
$("#errmsg").html(" Age must be greater than 18").show();
}
if((parseInt($("#quantity").val(), 10)>35))
{
$("#errmsg").html(" Age must be less than 35").show();
}
});
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.