javascript - The jQuery Validation `valid()` method returns 0 when required is not true -


I am using and applying it to a text box with the class numeral Found only to be points but not necessary when I call valid on the form then it works fine, but if I call valid () on the text box, it remains empty , It returns 0 without showing an error message and 0 if not set.

Does anyone know why it will appear to return to the valid input value?

Here is the code:

  & lt; Input type = "text" value = "" name = "kiloMetresTravelled" id = "kiloMetresTravelled" class = "numeral" />  

and the script

  & lt; Script type = "text / javascript '& gt; var isvalid = jQuery (' # kiloMetresTravelled '). Valid (); // isvalid == 0 if kiloMetres is empty then empty; / script>  < / Pre> 

check it, from:

creates "fields" required and Only digits.

You can do something like this:

  var isValid = jQuery ('# kiloMetresTravelled'). Valid () || jQuery (' # KiloMetresTravelled '). Val () == "";  

Comments