Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 JavaScript form validation Q
 New Topic  Topic Locked
 Printer Friendly
Previous Page
Author Previous Topic Topic Next Topic
Page: of 2

blackinwhite
Average Member

Turkey
657 Posts

Posted - 15 May 2002 :  14:44:36  Show Profile
how about that?
just put the code between your <head> tags.

I am using that for my forum forms.

<!-- Javascript function to check the submitted form has been filled in correctly before submitting -->
<SCRIPT language="JavaScript">
<!-- Hide from older browsers

//Check the enquiry form is filled in correctly
function CheckForm () {

//Initialise variables
var errorMsg = "";

//Check for a last name
if (document.FormName.SelectBox.value == "Other"){
errorMsg += "\n\tError: \t- Sorry, please enter a value for 'Other'.";
}

//Check for a last name
if (document.FormName.SelectBox.value == ""){
errorMsg += "\n\tError: \t- Sorry, please enter a value for 'Other'.";
}

//If there is aproblem with the form then display an error
if (errorMsg != ""){
msg = "______________________________________________________________\n\n";
msg += "Form wasn't sent because you didn't fill one or more of necessary fields.\n";
msg += "Please fill in the necessary fields and try again.\n";
msg += "______________________________________________________________\n\n";
msg += "Following fields must not be blank: -\n";

errorMsg += alert(msg + errorMsg + "\n\n");
return false;
}

return true;
}
// -->
</script>

Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 15 May 2002 :  14:45:29  Show Profile  Send ruirib a Yahoo! Message
I'll have a look at it in a couple hours. Get back to you as soon as I do it.

-------------------------------------------------
Installation Guide | Do's and Dont's | MODs
Go to Top of Page

blackinwhite
Average Member

Turkey
657 Posts

Posted - 15 May 2002 :  14:48:23  Show Profile
I forgat to mention, and add

onSubmit="return CheckForm(); in form part like,

<form method="post" name="FormName" action="form.asp" onSubmit="return CheckForm();">

Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 15 May 2002 :  20:13:14  Show Profile  Send ruirib a Yahoo! Message
FrutZle,

I've emailed you your new validation script. As far as I could test it, it works. That was some pretty neat validation code. I've learned a bit with it. Didn't know Dreamweaver could do it.

Let me know how it goes.



-------------------------------------------------
Installation Guide | Do's and Dont's | MODs
Go to Top of Page

Roland
Advanced Member

Netherlands
9335 Posts

Posted - 17 May 2002 :  12:07:53  Show Profile
quote:

FrutZle,

I've emailed you your new validation script. As far as I could test it, it works. That was some pretty neat validation code. I've learned a bit with it. Didn't know Dreamweaver could do it.

Let me know how it goes.



Sorry I didn't get back to you sooner, at least here, but we've been having some problems with one of our copy/print machines and I haven't had time to do much online yesterday.

Anyway, Ruirib gave me a great solution so I'm out of trouble.

Dreamweaver can't do that validation by default, at least versions 3 and 4 can't, so I downloaded an extention a long time ago. I checked Macromedia's download centre, but they don't have it anymore and unfortunately I have so many of them that I don't know which file is the one for that extention (short, indescriptive file names ).

Thank you all for your help. I really appreciate it, even if I don't use your codes.




http://www.frutzle.com

Snitz Exchange | Do's and Dont's
Go to Top of Page
Page: of 2 Previous Topic Topic Next Topic  
Previous Page
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.3 seconds. Powered By: Snitz Forums 2000 Version 3.4.07