/ 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.
Requires jQuery 1.2.6+
Each required field needs a class of "required" assigned to the input tag.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
//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 } });