How would you check if a certain character has been entered in a form field? An example would be an e-mail form…I want to check if it has the ‘@’ character. What command would you use? thanks
Btw, just give me the command and not the whole code for now so i can try it out myself
You’ll want to do it client-side, before the form actually gets submitted to the server, so Javascript is the best way to go. You could do it server side, after submit, then return to the form if invalid, but that’s clumsy for the user.
DigitalPimp is the resident Javascript whiz, when I checks in he should be able to at least point you in the right direction. I can code ASP script in my sleep, but I only know enough Javascript to be dangerous. =)
function validation() {
if(email.value.indexOf("@") != 1){
//email is correct
processForm();
}else{
alert("That isn't a valid email adress.");
}
}
Is processForm already a javascript function? I can’t test it because my server thing is very slow :-\ Oh yea i changed ‘youremailString’ to ‘email.value.indexOf’ where email is the form name. Would that work? thanks