Posted By

bcalloway on 02/18/09


Tagged

rails jquery Radiant


Versions (?)

Radiant mailer form jQuery validation


 / Published in: JavaScript
 

jQuery client-side form validation for the Radiant CMS mailer extension. Requires jQuery 1.2.6+ Each required field needs a class of "required" assigned to the input tag.

  1. //Contact form valiadation
  2. var form = $("form#contact-form");
  3.  
  4. form.submit(function(event) {
  5. form.find('label.error').filter('[generated=true]').empty();
  6.  
  7. if ( ((req_fields = form.find('.required[value=""]')).length > 0) || (form.find('select.required option:selected').val = "") ) {
  8. //req_fields.before('<p class="error" generated="true">This field is required</p>')
  9. req_fields.before('<span class="error" generated="true">This field is required</span><br />');
  10. $(req_fields).css('background', 'red');
  11. req_fields[0].focus();
  12. return false;
  13. } else {
  14. return true
  15. }
  16. });

Report this snippet  

You need to login to post a comment.