PDA

View Full Version : JavaScript Validate Hide Message



AE117
01-24-2009, 08:56 AM
Ok so what I got here is I show a div tag when the field is incorrect. What I am trying to do is hide that div tag when the filed is ok again.
Heres what I have can some one help me out here?

<!-- Begin Text and Chars
function validate(field) {
var valid = 'abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ.,&?-_!@#%: "'
var ok = "yes";
var temp;
for (var i=0; i<field.value.length; i++) {
temp = "" + field.value.substring(i, i+1);
if (valid.indexOf(temp) == "-1") ok = "no";
}
if (ok == "no") {
document.getElementById('validate').innerHTML='Field May Only Contain Characters Numbers and Special Characters .,&?-_!@#%:"';
document.getElementById('validate').style.visibility = "visible";
field.focus();
field.select();
}
else if (ok == "yes") {
document.getElementById('validate').style.visibility = "none";
field.focus();
field.select();
}
}
// End -->