Reputation: 11
Good afternoon all! I am looking for some guidance to see if this type of validation is possible. I work for a college and am using a form that pushes to our CRM when complete. I am looking for parsley to only validate the email address field IF they enter their college email address. Is this possible? I am trying to weave out personal email accounts and keep everything uniform with the same email address.
Thanks in advance!
Upvotes: 1
Views: 453
Reputation: 2062
You can do that e.g. by using data-parsley-pattern
and defining a pattern that matches only the required mail addresses. The pattern to validate against the mail addresses you mentioned in your comment might look like this:
.*@(mail\.)?walshcollege.edu$
This matches everything that:
*
) of arbitrary characters (.
)If you also want to make sure that an mail address is inserted you need to add data-parsley-required
as Parsley by default does not validate empty fields.
Also keep in mind that Parsley validation is only client side, so you should add validations in the server to really make sure that no wrong mail address is used.
Upvotes: 1