I use jQuery validation ( PLUGIN URL ) for most of my form validation:
I have the 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,
minlength: 6,
maxlength: 9
}
}
});
I have two problems with using space.
- min and max length will take a space as a character
- If a
number = truespace is used, it will return an error since the space is not a number
Is there a workaround? Please note that I want to continue to enter a space (for readability).
source
share