I want my "create an account" form to only accept .gov emails. If the user doesn't have a .gov email, they cannot create an account. Is this possible?

1 Answer 1


You can extend the prototype validations to create a custom one. Code:

Validation.add('validate-email', 'Please enter a valid Gmail address. For example [email protected].', function(v) { return Validation.get('IsEmpty').test(v) || /^([a-zA-Z0-9]+[a-zA-Z0-9._%-]*@gmail.com)$/i.test(v) })

Guide here.

  • Awesome guide! Thank you for the quick response! :-) Commented Jul 17, 2014 at 17:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.