fmx
02-27-2004, 02:18 PM
I am using a js alert window to verify a contact form.
function verify(){
var name = document.contact.fromname.value;
var email = document.contact.fromemail.value;
var mess = document.contact.message.value;
var outputmess = "Please complete the following field(s):\n___\n"
var errors = "";
if(!name){
errors += "> Your name\n";
}
if(!email){
errors += "> Your email\n";
}
if(!mess){
errors += "> message\n";
}
if(errors){
alert (outputmess + errors);
}
}
<input type="image" src="contactSend.jpg" onClick="verify()" alt="send" name="submitform">
The 2 problems im having is when the alert window does appear and the ‘ok’ button is clicked the form submits. How can I stop this?
And if the form is sent with an email missing a ‘@’ or a ‘.’ I get - page can not be displayed -
what is the best way to verify this?
see it in action --> here (http://dthom.com/contact.html)
function verify(){
var name = document.contact.fromname.value;
var email = document.contact.fromemail.value;
var mess = document.contact.message.value;
var outputmess = "Please complete the following field(s):\n___\n"
var errors = "";
if(!name){
errors += "> Your name\n";
}
if(!email){
errors += "> Your email\n";
}
if(!mess){
errors += "> message\n";
}
if(errors){
alert (outputmess + errors);
}
}
<input type="image" src="contactSend.jpg" onClick="verify()" alt="send" name="submitform">
The 2 problems im having is when the alert window does appear and the ‘ok’ button is clicked the form submits. How can I stop this?
And if the form is sent with an email missing a ‘@’ or a ‘.’ I get - page can not be displayed -
what is the best way to verify this?
see it in action --> here (http://dthom.com/contact.html)