function validate(picked){
var source = document.getElementById(picked);
switch(picked){
case "name":
var valid = /^[A-Z][-a-zA-Z]+$/;
//MIGHT BE VALUE OR VALUE()
if (!(valid.test(source.value))){
var error = document.getElementById("nm");
error.innerHTML = "sorry, invalid name!";
source.style.borderColor = "red";
}
break;
case "pass": break;
case "date": break;
case "year": break;
case "email": break;
}
}
So, as you can see, it's incomplete; but for the name; I'm using a regExp for validation; then I add text to a p-tag that's below every field (this is supposed to highlight the problem field and show up with red-text).
What I want to know is if you can see any problems (for debugging); because at the moment I'm limited to just Chrome's debugger.
Aucun commentaire:
Enregistrer un commentaire