codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Custom Form Validation Using JavaScript  gg5000 at 22:37 on Thursday, September 01, 2005
 

Hello folks, I'm new to this forum and I'm thankful to have found it!

I'm having an issue with a form. http://smithforjudge.com/3.htm

Basically I need to have one of the check boxes act as a validator for the form, where if checked, the form submits to the email and if the box isn't checked then another .htm doc comes up, giving the user further instructions.

Someone already wrote a bit of code for me. Just a simple if statement:

if (!theForm.C2.checked) {
// submit to new html page
// otherwise sumbit to set action page.
theForm.action = "/forum/errorpage.htm";
}

return (true);

This works because it doesn't submit an email unless the box is checked, except that when I specify the URL on the line that says:

theForm.action = "/forum/errorpage.htm", anything other that errorpage.htm gets an error that says:

Method Not Allowed
The requested method POST is not allowed for the URL /***.htm.

And the address bar on the browser does display the correct URL that I specified, but instead of that .htm, I get the error 405 page. The errorpage.htm gives a standard 404 error.

Any suggestions for making the code allow the URL that I specify to display correctly?

Thank you so much!

  Re: Custom Form Validation Using JavaScript  javabits at 00:12 on Friday, September 02, 2005
 

Have you tried changing the the form method to GET.

I would guess something like this might do it.

if (!theForm.C2.checked) {
// submit to new html page
// otherwise sumbit to set action page.
theForm.action = "/forum/errorpage.htm";
theForm.method = "GET";
}

try it and let us know.

semper fi...

  Re: Custom Form Validation Using JavaScript  gg5000 at 01:07 on Friday, September 02, 2005
 

That was it!!!

Thank you SOOOO much for your prompt response, that works great!

There is one thing though... I'm using FrontPage, and it tends to mess with the code. The page example I posted has <!--webbot bot="HTMLMarkup" startspan --> &
<!--webbot bot="HTMLMarkup" endspan --> around the HTML, which prevents FP from altering the code, but it also causes problems with the design view. So if I may bug you with another question...

where in the code should that IF statement be?

FrontPage erases IF statements from the code when you publish, even if you cut and paste your code, unless you use the tags above. But then the design GUI doesn't work.

As you can gather... I don't know JavaScript at all.

Again, thank you so much for being here and for helping me with this.

  Re: Custom Form Validation Using JavaScript  javabits at 01:23 on Friday, September 02, 2005
 

Glad to hear it worked. More of an educated guess than really me being an uber-expert in javascript.

But on to your next problem. Again I'm no FrontPage expert but what you could try is taking all the javascript and putting it in a seperate file. So take everything that is between the <script> tags and put it in a seperate file called validation.js

In your html file you would have something like the following

<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<script type="text/javascript" src="/js/validation.js"></script>
<title>Volunteers sign up</title>
</head>

The above assumes also that the javascript file is saved in a directory called js.

semper fi...








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Why Use Method?
•  Re: Help with filesystem object & displaying in a table
•  Re: Genetic Algorithm Help
•  Re: How to make an investment calculator
•  Re: line breaks in GUI
•  Re: Graph in Gui...
•  Graph in Gui...
•  Re: Counting zero values in a string
•  Re: Help!


Recent Articles
Multiple submit buttons with form validation
Understanding Hibernate ORM for Java/J2EE
HTTP screen-scraping and caching
a javascript calculator
A simple way to JTable
Java Native Interface (JNI)
Parsing Dynamic Layouts
MagicGrid
Caching With ASP.Net
Creating CSS Buttons


Site Survey
Help us serve you better. Take a five minute survey. Click here!

© Copyright codetoad.com 2001-2005