March 5, 201214 yr I have literally spent a good 10 or so hours on this. I have a simple form that asks for a name and a code then the user can click a submit button to basically say yes or no, the form works fine and the info is delivered to an email address as expected. However I have tried countless methods, plugins and tutorials to get the thing to validate but it just will not do it, every time without fail the form has just gone straight through to the .php action page. Here's the code for the form and its' immediate surrounding tags; <div id="main" role="main"> <aside class="rsvp-form-layout"> <img src="assets/img/rsvp-front.png" width="178" height="343" alt="Confirm RSVP below"> <div class="rsvp-form-inner" role="form"> <p>Enter the unique code found on your invite into the field below to confirm your attendance</p> <form action="contact.php" name="contact" method="POST"> <input type="text" name="fullName" class="rsvp-input-name" value="Enter Name" onBlur="if(this.value=='')value='Enter Name';" onFocus="if(this.value=='Enter Name')value=''" required /> <input type="text" name="code" class="rsvp-input-code" value="Enter Code" onBlur="if(this.value=='')value='Enter Code';" onFocus="if(this.value=='Enter Code')value=''" required /> <input type="submit" name="submit-yes" class="submit-yes" value="I am attending" /> <input type="submit" name="submit-no" class="submit-no" value="I can't make it" /> </form> </div> </aside> Can anyone spot any reason that this form might not play ball with validation scripts? I'd show you the script but I've tried that many and with various different tweaks that I can't. But for example when I tried using the popular jQuery validate plugin, I linked it to my HTML, copied some demo script for the header section (also tried doing this in a separate JS file), changed the parameters i.e. the names it was referencing and as far as I can see that should at least stop an empty form from being sent? I'm hoping there's something in the HTML that is obviously not working well with JS.
March 5, 201214 yr Have you done any server side validation or are you just using javascript? Javascript can be turned off and so you should have a fall back onto server side validation, just incase you haven't.
March 5, 201214 yr Author Have you done any server side validation or are you just using javascript? Javascript can be turned off and so you should have a fall back onto server side validation, just incase you haven't. Not at the moment, I'll look into implementing some kind of fallback when or more likely if I sort the JS side of it out.
March 5, 201214 yr You should do the server side first so you know that it is definitely validating, and then do client side once after. Server side is pretty easy, it's just all in php
March 5, 201214 yr Author You should do the server side first so you know that it is definitely validating, and then do client side once after. Server side is pretty easy, it's just all in php Not a bad idea that. Thanks.
March 5, 201214 yr Author For anyone interested or who may perhaps come across this issue, as I suspected it was something simple I'd overlooked. The onBlur adds a value to the field so all this time I was submitting the form the validation was working perfectly fine and allowing the non-blank form to go through freely. Doh is the phrase I believe.
Create an account or sign in to comment