Simple Javascript validation Code

var log_validate_temp = Array(‘login_email’,’login_passwd’);
for(var i=0;i<log_validate_temp.length;i++)
{
$(‘#’+log_validate_temp[i]).blur(function(){
var tempVal = $(this).val();
if(tempVal.trim()==”)
{
$(this).css(“border”,”1px solid rgba(255, 102, 0, 0.4)”).css(“box-shadow”,”inset 0 1px 1px rgba(255, 102, 0, 0.4)”);
}else{
$(this).css(“border”,”1px solid rgba(0, 161, 97, 0.4)”).css(“box-shadow”,”inset 0 1px 1px rgba(0, 161, 97, 0.4)”);
}
});
}

Advertisements