Jump to content

My new newform had flaw..


moneytree

Recommended Posts

Hi everyone,Good day to you.I had just created my new html code for my webform,however,it seemd like it allowed submission of the opt-in form without filling up the info by clicking on the submit button.May I know what wrong with it ? How to correct this problem ?The following is my webform code :--------------------------------------------------------------------------------------------------------------------------------------------<div id="formbox"><h3>Get Your Free Gifts !</h3><form METHOD="post" ACTION="http://moneymakeyourich.com/cgi-bin/formmail.pl"><input type=hidden name="recipient" value="moneytree@moneymakeyourich.com"><input type=hidden name="subject" value="Your Subject">First Name :<input type=text name="realname" size="20"><br>Last Name :<input type=text name="lastname" size="20"><br>Email           :<input type=text name="email" size="20"><br><input type="Submit" value="submit"></form><p><b>Important</b>:I will never share your information with anyone !</p>--------------------------------------------------------------------------------------------------------------------------------------------Thank you.Best regardsManicui

Link to comment
Share on other sites

Well, forms submit even with blank fields, that's how they work. If you want to prevent it you're going to have to use javascript. And as a safety measure, detect if fields are empty with the server-side language that processes the form too.

Link to comment
Share on other sites

I lifted this out of one of my pages. Then I tinkered a little to show just the relevant items. You'll want to experiment.FORM SNIPPET HERE<form id='myForm' onsubmit='mySubmit();return false'> <input type='text' id='userName'> <div id='warn2' style="{visibility: hidden;}"> Enter some text, please. </div> </form>END FORM SNIPPETSCRIPT SNIPPET HEREfunction mySubmit(){ if (document.getElementById('userName').value == ''){ document.getElementById('warn').style.visibility = 'visible'; setTimeout("document.getElementById('warn').style.visibility = 'hidden';",5000); }else{ document.getElementById('myForm').submit(); }}END SCRIPT SNIPPET

Link to comment
Share on other sites

Hi Ingolme,Deirdre's Dad,Good day to you.Many thanks for your advcie to me over webform issue.Referring to your advice as follow :---------------------------------------------------------------------------------------------------------FORM SNIPPET HERE<form id='myForm' onsubmit='mySubmit();return false'><input type='text' id='userName'><div id='warn2' style="{visibility: hidden;}">Enter some text, please.</div></form>END FORM SNIPPETSCRIPT SNIPPET HEREfunction mySubmit(){if (document.getElementById('userName').value == ''){document.getElementById('warn').style.visibility = 'visible';setTimeout("document.getElementById('warn').style.visibility = 'hidden';",5000);}else{document.getElementById('myForm').submit();}}END SCRIPT SNIPPET---------------------------------------------------------------------------------------------------May I know how to get it done over my exisitng webform code ? Delete it and replace the entire FROM and SCRIPT which offered by you into my home page ? Or just insert the SCRIPT without removing my existing webform code ?Thank you.Best regardsManicui

Link to comment
Share on other sites

Egad! I hoped the word 'snippet' would not suggest such a rash action, but rather the sort of method you might use. In short, don't delete or replace ANYTHING on my sayso, because I didn't say so. At most do the following: In your form tag, along with your other stuff, add something like this:onsubmit='mySubmit();return false'In your script, along with everything else, add a function like this:function mySubmit(){if (document.getElementById('whatever_ID_is_appropriate').value == ''){// give your user some feedback}else{document.getElementById('myForm').submit();}}

Link to comment
Share on other sites

Egad? Form snippets are supposed to give you ideas. Don't c/p or else your scripts will most likely stop working altogether. General rule...

Link to comment
Share on other sites

Hi Deirdre's Dad,Good day to you.It is really nice to hear from you again to answer my queris over webform issue.The following amended code is based on my understanding to your replied for your review and advice,is it correct ? Amended code :--------------------------------------------------------------------------------------------------------------------------------------------<div id="formbox"><h3>Get Your Free Gifts !</h3><form METHOD="post" ACTION="http://moneymakeyourich.com/cgi-bin/formmail.pl"onsubmit='mySubmit();return false'>function mySubmit(){if (document.getElementById('whatever_ID_is_appropriate').value == ''){// give your user some feedback}else{document.getElementById('myForm').submit();}}<input type=hidden name="recipient" value="moneytree@moneymakeyourich.com"><input type=hidden name="subject" value="Your Subject">First Name :<input type=text name="realname" size="20"><br>Last Name :<input type=text name="lastname" size="20"><br>Email           :<input type=text name="email" size="20"><br><input type="Submit" value="submit"></form><p><b>Important</b>:I will never share your information with anyone !</p>--------------------------------------------------------------------------------------------------------------------------------------------I am sorry for posted this queries to you and appreciate your advice to it.Thank you.Best regardsManicui

Link to comment
Share on other sites

Getting there. I assume these two elements contain the values you want to check:<input type=text name="lastname" size="20"><input type=text name="email" size="20">If so, better give each an id so you can access their values correctly:<input type=text name="lastname" id="lastname" size="20" /> <input type=text name="email" id="email" size="20" /> Now your validator function might read like this:function mySubmit(){var name = document.getElementById('lastname').value;var email = document.getElementById('email').value;if (!name || !email){// give your user some feedback}else{document.getElementById('myForm').submit();}}Hope this helps.

Link to comment
Share on other sites

Hi Deirdre's Dad,Synook,Ingolme,I just wanted to share my joy with you as my webform work finally with your helped ! Thank you.However,I do encounted another issue over second subscription to same offer as my webform can't detect it.It should show the following error message when second subscription detected :An Error Occurred Notice:Our records indicate that you are already subscribed to this list and have verified your subscription. May I know how to get it done ?Thank you.Best regardsManicui

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...