Implementing Digits restriction Using JQuery
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.
View Answers
December 15, 2010 at 12:55 PM
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();
}
});
Ads
Related Tutorials/Questions & Answers:
Implementing Digits restriction Using JQuery
Implementing Digits restriction Using JQuery Hi Sir
I have....
Please provide code.
You can implement these two things
using ASCII code...("
Digits Only").show();
return false
Advertisements
Vertical news slider using jquery
Vertical news slider
using jquery how to creatw vertical news slider
using jquery
Sorry for wrong category but i cant get my
jquery category
Show Limited Data Using jquery
Show Limited Data
Using jquery How to show limited results in
JQuery... it
using JQuery?
See the
JQuery example to show the limited fetch results in
JQuery.
var comments = $('.description_text').size();
if (comments >
Form validation Using Jquery Plugin
Form validation
Using Jquery Plugin Hello sir
I want to implement form validation
using JQuery Plug-in. My code is :
<html>
<style type...;/form>
</body>
</html>
Please provide me
JQuery code regarding
Html form validation using jquery
Html form validation
using jquery Hi i am
using form with html. Form elements like textbox, radio,checkbox,listbox i was used now how to validate the elements
using submit
jquery option
HTML form validation using jquery
HTML form validation
using jquery Is there any way for validating html elements common under a class by giving its class name in
jquery validation code..that means validating all elements by
using its class name if those
Disabling submit button using jQuery
Disabling submit button
using jQuery Hello Sir
I want to know - is there any way or approach to disable client side form's "Submit" button.
Please give code also.
For all submit buttons, via
JQuery, it'd
Using the jQuery event object
Using the
jQuery event object
Using the
jQuery event object
JQuery... to these
standards, this system normalize the event object.
jQuery. Event
Find Browser & it's version using jQuery
Find Browser & it's version
using jQuery Hi sir
I heard that
JQuery have some method which can be used to find the Browser name & its version.
I need the code which checks the browser and if it is "Mozilla", it will show
Crop image Using JQuery, servlet or JSP.
Crop image
Using JQuery, servlet or JSP. Hi sir
I need the code of Cropping image
using JQuery with the help of servlet or JSP. I need both the code Client side as well as of server side.
Please Help me
Auto grow Text Area using jQuery plug-in
Auto grow Text Area
using jQuery plug-in Hi sir
How can we make a textarea auto grow ? What is the name of the plug-in used for auto grow text area.
Please mention code with your reply
pdf restriction
pdf restriction i have certain pdf files that have restrictions on it as copy ,read,extract text etc..
i want to remove
restriction by java code.
so is there any way to do this?
plz help
thanks in advance
rohit
how to print HTML using javascript or Jquery
how to print HTML
using javascript or Jquery is there any way to print a document(created
using Html and javascript) without
using window.print, which works for all the browser specially chrome and firefox, I have used
Passing classid or name in request using Jquery
Passing classid or name in request
using Jquery Hi, I am new to JQuery.I have a servlet that I am calling
using jquery.I have some parameters like filename,userid that I am passing to the servlet to upload a file.I have created
jquery
jquery how to display the leaves taken or holidays of the year or half working days in a calendar in some colors to identify the days
using jquery plugin
JQuery
JQuery how to use
jquery
JQuery
JQuery how to create
jquery auto-complete textbox ? in which data...://www.roseindia.net/tutorial/
jquery/autoSuggestTextbox.html
thank you for fast reply. when i m
using key-down than cursor is not going down.i m not able