I want to use javascript code. In the javascript code there is a "alert (msg)" and "return false" when the condition is false, and the execution don´t stop here.
What sentence I have to put in the javascript code for to stop the form code execution when the condition is false?
Thank you very much.
What sentence I have to put in the javascript code for to stop the form code execution when the condition is false?
Thank you very much.
Great, one idea is to make onsubmit function at the form tag and make it return false.
Regards
Max
Regards
Max
I validate all the my fields, but I want to check that one of chechbox group is checked at least. For this I did an javascript, but if the javascript code is true, send the form without the validation that offer the component. If don´t put the javascript code, the users can send me with all the checkboxes with checked=false.
The code of the javascript is the next
function checkform(){
if ((!document.ChronoContact_Peticion_cafes.Agua.checked) && (!document.ChronoContact_Peticion_cafes.Cafes.checked) && (!document.ChronoContact_Peticion_cafes.Pastas.checked) && (!document.ChronoContact_Peticion_cafes.Zumos.checked) && (!document.ChronoContact_Peticion_cafes.Infusiones.checked)) {
alert('Debes marcar un servicio al menos');
}
else document.ChronoContact_Peticion_cafes.submit();
}
The code of the javascript is the next
function checkform(){
if ((!document.ChronoContact_Peticion_cafes.Agua.checked) && (!document.ChronoContact_Peticion_cafes.Cafes.checked) && (!document.ChronoContact_Peticion_cafes.Pastas.checked) && (!document.ChronoContact_Peticion_cafes.Zumos.checked) && (!document.ChronoContact_Peticion_cafes.Infusiones.checked)) {
alert('Debes marcar un servicio al menos');
}
else document.ChronoContact_Peticion_cafes.submit();
}
Hi,
if this works for you then that's fine, my idea is to add onsubmit="return checkform(this);" in the form tag attachment
then the JS code will look like this :
if this works for you then that's fine, my idea is to add onsubmit="return checkform(this);" in the form tag attachment
then the JS code will look like this :
function checkform(form){
if(form.name.value == ''){ return false; }
return true;
}
I´m sorry but this solution don´t work. I put the tag "<form onsubmit="return checkform(this)">" in line 1 to form html code, and in javascript there is a function "checkform(form)" and never is in execution. I don`t know that is problem-
Thank you
Thank you
Hi vjmazcu,
You must not put <form> tags in the form code as CF adds them automatically and you end up with two sets.
Instead put the code onsubmit="return checkform(this);" in the Form Tag attachment box on the General tab for your form.
Bob
You must not put <form> tags in the form code as CF adds them automatically and you end up with two sets.
Instead put the code onsubmit="return checkform(this);" in the Form Tag attachment box on the General tab for your form.
Bob
This topic is locked and no more replies can be posted.
