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; }    }); }); 

full code

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

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -