PDA

View Full Version : Validation revisited


zoobie
09-09-2002, 06:25 AM
Could someone change this working script so it gets alerted once after passing validation with alert("Please, please, PLEASE double-check your email address one last time!") ?

Me so grateful :D

<SCRIPT>
<!--
function checkData() {
var correct = true
if (document.form.receiver.value == "") {correct = false; alert("Please enter email address!")}
if (document.form.graphic.value == "") {correct = false; alert("Please select your graphic!")}
if (document.form.comments.value == document.form.comments.defaultValue) {correct = false; alert(" Please type your comments!")}
if (document.form.comments.value == "") {correct = false; alert(" Please type your comments!")}
return correct
}
//-->
</SCRIPT>

joh6nn
09-09-2002, 06:43 AM
can we see the rest of the page?

zoobie
09-09-2002, 07:23 AM
All it has on it is an imageviewer and this form. This validation works fine...but needs the final touch. I'm not very good with javascript because I've forgotten a lot over the year.

Thanks :D

joh6nn
09-09-2002, 07:41 AM
var correct = false;
function checkData() {
if ( correct == false ) {
if (document.form.receiver.value == "") {alert("Please enter email address!"); return false;}
if (document.form.graphic.value == "") {alert("Please select your graphic!"); return false;}
if (document.form.comments.value == document.form.comments.defaultValue) {alert(" Please type your comments!"); return false;}
if (document.form.comments.value == "") {alert(" Please type your comments!"); return false;}
correct = true; return false;
}
else {
return true;
}
}

zoobie
09-09-2002, 08:44 AM
Works like a charm...Thanks a lot, John.

What's nice about this type is that it only gives the user one alert per missing field at a time whereas with the one I was using before, it cycled through all alerts/fields before allowing the user to continue.

Thanks again :D

PS - I guessed where the final alert went from your previous posts...heh heh :cool: