I use the jQuery Validation plugin and I have a text box with a class digits
to make it be numbers only, but not required. When I call validate on the form, it works fine, but if I call valid()
in the text box when it is empty, it returns 0, despite the fact that the error message is not displayed and does not need to be set.
Does anyone know why it will return this for an apparent valid input value?
Here is the code:
<input type="text" value="" name="kiloMetresTravelled" id="kiloMetresTravelled" class="digits"/>
and script
<script type="text/javascript'>
var isvalid = jQuery('#kiloMetresTravelled').valid();
//isvalid == 0 when kiloMetresTravelled is blank
</script>
source
share