I have been trying to add validation to the phone field so it would accept only 10 to 14 digits (other better UK phone validation methods are also welcome).
I am using jQuery Validation Plugin.
<form class="form" id="lg.callback.form" action="[[~[[*id]]]]" method="post">
<input type="hidden" name="nospam:blank" value=""/>
<label for="name"> Name: <span class="error">[[!+fi.error.name]]</span></label>
<input id="name" type="text" name="name" value="[[!+fi.name]]" required />
<label for="phone"> Phone: <span class="error">[[!+fi.error.phone]]</span></label>
<input id="phone" type="text" name="phone" value="[[!+fi.phone]]" class="phone"/>
<input type="submit" value="Request a call back"/>
</form>
<script>
$("#lg.callback.form").validate();
</script>
I did try the following:
$("#lg.callback.form").validate({
rules: {
phone: {
required: true,
digits: true,
minlength: 10,
maxlength: 14
}
}
})
but it does not work as expected.
Advice would be appreciated.