iEntry 10th Anniversary Forum Rules Search
WebProWorld
Register FAQ Calendar Mark Forums Read
Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Share Thread: & Tags

Share Thread:

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-07-2008, 08:40 PM
AuctionHugh's Avatar
WebProWorld Pro
 
Join Date: Jul 2004
Location: Kalamazoo Michigan
Posts: 103
AuctionHugh RepRank 0
Question Form Validation not Working - help please?

I basically use the same form which I modify from site to site as needed - why reinvent the wheel?

This one has a lot of fields, but I am only validating three of them - name cannot be blank, email has to be an email address, and the spam catcher has to be 777.

(Note that in my form2email.php file I do more checking for valid email, same referrer, 777, etc, which really cuts down on spam - probably many discussions on this elsewhere.)

Anyway, for some reason in this incantation of the form it is allowing the form to be submitted with both the name and/or email fields blank.

It is probably something pretty obvious, but I'm missing it. I'd appreciate it if one of you experts (and I don't mean that sarcastically) could glance this over and tell me what is going on. Thanks!

edit - my form seems to be too long to submit so I'm cutting out the parts I'm not trying to validate:

HTML Code:
                  <h1 class="headings">Music Selection Form</h1>
                 <form name="MusicSelection" method="post" action="FormToEmail.php">
                  <table width="100%" border="0" cellpadding="8" cellspacing="0" class="bodytext">
                    <tr>
                      <td width="48%"><strong>Your Contact Information</strong></td>
                      <td width="52%">&nbsp;</td>
                    </tr>
                    <tr>
                      <td><div align="right">Your Name:</div></td>
                      <td width="52%"><input name="Name" type="text" class="formstyle" id="Name" size="24" maxlength="75" /></td>
                    </tr>
                    <tr>
                      <td><div align="right">Your Email:</div></td>
                      <td width="52%"><input name="email" type="text" class="formstyle" id="email" size="28" maxlength="100" /></td>
                    </tr>
                    <tr>
                      <td colspan="2"><div align="center"><em>Please note: We will not share or release<br />
                        your personal information with any other source.</em></div></td>
                      </tr>
......
                    <tr>
                      <td><div align="right"><span class="bluebold">Enter the number 777 to help us avoid spam:</span></div></td>
                      <td><input name="AvoidSpam" type="text" class="formstyle" id="AvoidSpam" tabindex="10" size="50" maxlength="3" /></td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                    

<td><input name="SendRequest" type="submit" class="formstyle" id="SendRequest" onClick="MM_validateForm('Name','','R','email','','RisEmail','AvoidSpam','','RinRange777:777');return document.MM_returnValue" value="Send Request">        
                      </td>
                    </tr>
                  </table>
                  </form>

Last edited by AuctionHugh; 12-07-2008 at 08:42 PM.
Reply With Quote
  #2 (permalink)  
Old 12-08-2008, 12:43 PM
Dubbya's Avatar
WebProWorld 1,000+ Club
WebProWorld MVP
 
Join Date: Nov 2006
Location: Steinbach, Manitoba, Canada
Posts: 1,300
Dubbya RepRank 4Dubbya RepRank 4Dubbya RepRank 4Dubbya RepRank 4Dubbya RepRank 4
Default Re: Form Validation not Working - help please?

Without seeing your Javascript validation routine, the onClick calling "MM_validateForm" looks like the culprit.

Try this:
Code:
<form name="MusicSelection" method="post" action="FormToEmail.php" onsubmit="return false;">
Your Javascript validation routine should submit the form after it validates and returns "true".

In the event that this doesn't work, you'd do well to post your MM_validateForm Javascript as we've no way of telling where you might have made an error.
Reply With Quote
  #3 (permalink)  
Old 12-08-2008, 01:24 PM
Moderator
WebProWorld Moderator
 
Join Date: Oct 2003
Location: Alberta, Canada
Posts: 878
weegillis RepRank 6weegillis RepRank 6weegillis RepRank 6weegillis RepRank 6weegillis RepRank 6weegillis RepRank 6weegillis RepRank 6
Default Re: Form Validation not Working - help please?

If MM_validateForm returns true then the form should carry out the action, else kick out on false, as I read this. Perhaps the validation should occur "onsubmit" rather than "onclick" whereby true will effect an action, and false will revert to an error message?
Reply With Quote
  #4 (permalink)  
Old 12-08-2008, 03:09 PM
AuctionHugh's Avatar
WebProWorld Pro
 
Join Date: Jul 2004
Location: Kalamazoo Michigan
Posts: 103
AuctionHugh RepRank 0
Lightbulb Re: Form Validation not Working - help please?

Quote:
Originally Posted by Dubbya View Post
Without seeing your Javascript validation routine, the onClick calling "MM_validateForm" looks like the culprit.
You hit the nail right on the head. My Javascript had a problem - a little fixin' and all is well. Thanks much for your help!
Reply With Quote
  #5 (permalink)  
Old 12-08-2008, 06:02 PM
sharonjackson's Avatar
WebProWorld Member
 
Join Date: Nov 2008
Location: Duncan, BC Canada
Posts: 66
sharonjackson RepRank 1
Default Re: Form Validation not Working - help please?

If you are using Dreamweaver, I think it is a bug. I have never gotten MM_ValidateForm to work properly if I specify that the email must be an email address. It works if you tell it that it can be anything, however.
Reply With Quote
  #6 (permalink)  
Old 12-08-2008, 06:35 PM
AuctionHugh's Avatar
WebProWorld Pro
 
Join Date: Jul 2004
Location: Kalamazoo Michigan
Posts: 103
AuctionHugh RepRank 0
Default Re: Form Validation not Working - help please?

Once I fixed my obvious mistake (I'm sparing myself embarrassment by not posting exactly what it was here), it works fine. Email addresses work, but blank or text that does not contain a @ receives an error.
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with form validation jasonweb Web Programming Discussion Forum 12 03-10-2006 12:22 PM
php form validation of textarea ozchris Web Programming Discussion Forum 7 09-09-2005 04:16 AM
Form validation: PHP or Javascript? ozchris Web Programming Discussion Forum 6 04-21-2005 01:22 PM
New site,...working on Validation and SEO mcohen Search Engine Optimization Forum 3 05-04-2004 12:34 PM
Form validation MasterT Web Programming Discussion Forum 4 03-20-2004 11:37 AM


All times are GMT -4. The time now is 09:33 PM.



Search Engine Optimization by vBSEO 3.3.0