I'm using jQuery Validation (PLUGIN URL) plugin for most of my form validation:
I have following example (LIVE EXAMPLE):
FORM:
<form class="form" id="feedback-form" method="post" action="#">
<label for="phone">Contact number:</label>
<input type="text" value="" id="phone" name="phone" class="required">
<br class="clr">
<div class="form-buttons">
<input id="submit" type="submit" value="Submit" class="button" >
</div>
<br class="clr">
<br /><br />
</form>
jQuery:
$("#feedback-form").validate({
rules: {
phone: {
number: true, // as space is not a number it will return an error
minlength: 6, // will count space
maxlength: 9
}
}
});
I have two issues, both relating to space usage.
number = true
and space is used, it will return error as space is not a numberIs there any workaround this? Have any of you bumped in on the same problem? Please note I want to keep allowing to type in space (for readability).
You can add a beforeValidation callback to send the value without spaces, take a look here: Jquery Validator before Validation callback, it seems to be what you're looking for
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With