Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery validation only digits

I am having the jquery.validate.js plugin and it is working fine for me.

My question is :

I am having a textbox and this textbox is mandatory and should only accept digits.

In the js, I can see that there is validation for the digits and the problem is that I do not know how to use it.

I only knew how to make the field required by putting in the textbox field <class="required">

So, how can I add one more validation criteria to accept only digits.

Thanx

like image 655
maas Avatar asked Aug 11 '10 07:08

maas


People also ask

Is numeric JQuery validation?

The isNumeric() method in jQuery is used to determine whether the passed argument is a numeric value or not. The isNumeric() method returns a Boolean value. If the given argument is a numeric value, the method returns true; otherwise, it returns false. This method is helpful as it decreases the lines of code.

What is JQuery validation?

Validation in JQuery: Using JQuery, a form is validated on the client-side before it is submitted to the server, hence saves the time and reduce the load on the server. Form Validation means to validate or check whether all the values are filled correctly or not.


2 Answers

to check it add

$("#myform").validate({   rules: {     amount: {       required: true,       digits: true     }   } }); 

http://docs.jquery.com/Plugins/Validation/Methods/digits

like image 74
Haim Evgi Avatar answered Sep 23 '22 13:09

Haim Evgi


$("#mobile_number").validate({             rules: {                  mobile_number: {required: true,number:true}             },             messages: {                 mobile_number: {required: "Please Enter Your Mobile Number",number:"Please enter numbers Only"}             }   }); 
like image 22
Vignesh V Avatar answered Sep 20 '22 13:09

Vignesh V