I have read the documentation (and then some) pertaining to FormIt and adding custom fields. So my question is not for lack of looking, its just I don't 100% understand the FormIt validation lingo.
I was able to add a phone number field to my contact form. I was also able to add the most generic validation method (required). That is: if the field is left empty it says: "This field is required".
Is it possible to also require at least 7 digits? I don't want people to throw any old quick text into the phone field. I would like to force them to enter a valid phone number (or come close without too much hassle).
My form page has this:
[[!FormIt?
&hooks=`recaptcha,spam,email,redirect`
&submitVar=`go`
&emailUseFieldForSubject=`1`
&emailTpl=`MyEmail`
&emailTo=`[email protected]`
&redirectTo=`40`
&validate=`name:required,
phone:required,
email:email:required,
subject:required,
hear-about-us:required:minLength=`1`,
text:required:stripTags`
&recaptchaTheme=`red`
]]
My actual form his this for the phone number field:
<label for="phone">Phone Number: <font color="#FF0000"><span class="error">[[+fi.error.phone]]</span></font>
</label><input id="phone" name="phone" type="text" value="[[+fi.phone]]" />
I just don't know how to require both text to start, and then make sure this text is at least 7 digits long, within the same validation area. What I would also like to do is, if they entered less than 7 characters, the validation error sends a modified error message of: "Please enter a valid phone number" instead of the basic message provided. That is assuming this is not too difficult.
I just don't know how, where to do this.
[ed. note: wbbuilder last edited this post 11 years, 6 months ago.]