Return to Snippet

Revision: 11791
at February 18, 2009 16:34 by bcalloway


Initial Code
//Contact form valiadation
var form = $("form#contact-form");

form.submit(function(event) {
  form.find('label.error').filter('[generated=true]').empty();
  
  if ( ((req_fields = form.find('.required[value=""]')).length > 0) || (form.find('select.required option:selected').val = "") ) {
    //req_fields.before('<p class="error" generated="true">This field is required</p>')
    req_fields.before('<span class="error" generated="true">This field is required</span><br />');
    $(req_fields).css('background', 'red');
    req_fields[0].focus();
    return false;
  } else {
    return true
  }
});

Initial URL

                                

Initial Description
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.

Initial Title
Radiant mailer form jQuery validation

Initial Tags
rails, jquery

Initial Language
JavaScript