rockonmetal Posted August 28, 2007 Share Posted August 28, 2007 Ok, I am new, I have no idea where to post this so if its in the wrong place let me know!!! Ok, so I hardly know any php code... i am wondering if someone could help me write a validation for my form that would be great, I have the form code below... <form action="uploader.php" method="post" enctype="multipart/data"> <input type="hidden" name="3p42r3ad3a4than32" value="329r8g" /> <div class="pureadd"> <br> <br>Your Name: <br><input type="text" name="Name" class="input" /> <br>Your Email: <br><input type="text" name="Email" class="input"/> <br> <script type="text/javascript"> var d = new Date() document.write("<input type='hidden' value='"+Date()+"' name='time' />") </script> <br> <br>Agree To Terms of Service <br><input type="checkbox" name="TermsOfService" value="Agreed" /> Yes I Agree To the Terms of Service <br> File Description: <br> <textarea rows="5" cols="40" name="description" id="maxcharfield" onKeyDown="textCounter(this,'progressbar1',200)" onKeyUp="textCounter(this,'progressbar1',200)" onFocus="textCounter(this,'progressbar1',200)" class="textarea"></textarea><br /> <div id="progressbar1" class="progress"></div> <input type="submit" class="input"> </div> </form> Don't worry about the first hidden input thats totally under controll. I would like for the form to validate when the user clicks the submit button and if the form is valid then it goes and if not the form does not send... thanks! Quote Link to comment Share on other sites More sharing options...
effigy Posted August 28, 2007 Share Posted August 28, 2007 There are some e-mail patterns here. For the name, I assume you only want letters and spaces, but within which character set? ASCII would be [a-zA-Z ]+, and Unicode [\p{L}\p{Zs}]+. You'll also need to consider punctuation if it is an entire name, e.g., "Bob Smith, Jr." Quote Link to comment Share on other sites More sharing options...
miseleigh Posted August 30, 2007 Share Posted August 30, 2007 If you don't want it to send until the input is valid, what you really need is javascript. Try this site: http://www.w3schools.com/js/js_form_validation.asp edit: this site is more of a tutorial: http://www.tizag.com/javascriptT/javascriptform.php Quote Link to comment Share on other sites More sharing options...
effigy Posted August 30, 2007 Share Posted August 30, 2007 If you don't want it to send until the input is valid, what you really need is javascript. ...and if the user has Javascript disabled, you will receive unchecked content. If anything, use a combination of the two. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.