i'm writing javascript validator
and i change input font color when the input is incorrect
but i want this input font color to be changed back when the input is correct
i cannot do eg
[code=javascript]
var email1= form.email1.val ue;
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (!filter.test(e mail1)) {
document.getEle mentById("email 1").style.color ="red";
if(language=="p olish"){
form.email1.val ue="***Proszę wpisać poprawny email!";}
else {form.email1.va lue="***Please enter the right email!";}
document.getEle mentById("email 1").style.color ="black"; <--change back
return false;
}
[/code]
because even when the field has incorrect value the font color is black instead of red
thank You
and i change input font color when the input is incorrect
but i want this input font color to be changed back when the input is correct
i cannot do eg
[code=javascript]
var email1= form.email1.val ue;
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (!filter.test(e mail1)) {
document.getEle mentById("email 1").style.color ="red";
if(language=="p olish"){
form.email1.val ue="***Proszę wpisać poprawny email!";}
else {form.email1.va lue="***Please enter the right email!";}
document.getEle mentById("email 1").style.color ="black"; <--change back
return false;
}
[/code]
because even when the field has incorrect value the font color is black instead of red
thank You
Comment