jQuery form validation function/plugin -
emaili building function validate forms, can use upcoming projects. little bit stuck @ moment, need find way add background red if inputs of form empty. far:
$(document).ready(function() {
$('label').click(function() { var haserror = false, emailreg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/, form = $('form'), radio_check = $('.tick .test'), input = $('input:not(.submit)'), emailaddressval = $("#email").val(), email = $('#email'); if(email.val() === ''){ email.css('background-color', 'red'); } else if(!emailreg.test(emailaddressval)) { email.css('background-color', '#faa'); haserror = true; } if(haserror == true) { return false; } }); });
so far it's checking if email input empty , if there wrong email format. first thing check if there empty input fields , if yes assign them css property.
Comments
Post a Comment