openrightsgroup / blocked-org-uk

Template front-end code, markup, style-sheets, images and other assets for the Censorship Monitoring Project (blocked.org.uk)
https://www.blocked.org.uk/
GNU General Public License v3.0
13 stars 5 forks source link

Email address not mandatory when "please email me" check-boxes are set #51

Closed graphiclunarkid closed 10 years ago

graphiclunarkid commented 10 years ago

Reproduction steps:

  1. Visit http://stage.blocked.org.uk/
  2. Enter a URL to check.
  3. Ensure the email address field is either blank or contains a string that is not a valid email address.
  4. Set either or both of the following check boxes: "I'm happy for ORG to contact me if I have any questions" or "I'd like to join the ORG mailing list (view privacy policy)."
  5. Submit the form.

Expected: validation error (must supply an email address to be contacted or subscribed to the list)

Actual: form is submitted.

See also #5

mkillock commented 10 years ago

Looks like this would require a custom validation snippet.

http://rtfm.modx.com/extras/revo/formit/formit.validators

So to be clear, this is what is wanted?

  1. 'Join ORG mailing list' or 'contact ORG' ticked: Valid email required
  2. Neither ticked: email not required
graphiclunarkid commented 10 years ago

Yes, that's right.

mkillock commented 10 years ago

I've written a custom FormIt validator snippet (EmailChecker) for this purpose. Currently implemented on stage home page

FormIt call needs following extra entries:

&customValidators='EmailChecker' &validate='4DRXNE97LE:required, SSQ97709WZ:EmailChecker, url:blank'

Also, have added validator error message:

    [[!+fi.error.SSQ97709WZ:!empty=`<p><a href="[[~[[*id]]]]#4DRXNE97LE">Valid email is required with selected option(s)</a></p>`]]