rayskelton
asked on
For HTML forms, How do I validation through JavaScript and email form?
For HTML forms, How do I validation through JavaScript and email form? I can validate the form successfully through JavaScript and can also email the form but not both. Is this possible?
This works
<form name="myForm" onSubmit="return isValidData(firstname, lastname, email)" >
This works
<form name="myResumeForm" action="mailto:sskelton@be llsouth.ne t" method="post">
How do I combine the two to validate the form and then email the form?
This works
<form name="myForm" onSubmit="return isValidData(firstname, lastname, email)" >
This works
<form name="myResumeForm" action="mailto:sskelton@be
How do I combine the two to validate the form and then email the form?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Are you sure?
If isValidData() returns false, it should halt execution.
Try the below code.
If isValidData() returns false, it should halt execution.
Try the below code.
<form name="myResumeForm" onSubmit="return isValidData()" action="mailto:sskelton@bellsouth.net" method="post">
<input type="button" onclick="setValid();" value="Toggle isValidData()"/>
<input type="submit"/>
</form>
<script>
var isValid = false;
function setValid(){
isValid = isValid ? false : true;
}
function isValidData(){
return isValid;
}
</script>
I think it might help if you post more code, or preferably a demo.
ASKER
This works great. Thanks for your help
ASKER
This sends email, regardless of field validation
<form name="myForm" onSubmit="return isValidData()" action="mailto:abc@bellsou
I need to only send email if the field validation returns false.