Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

I have tried countless ways to get this form to validate...? Help!

Featured Replies

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. :blink:

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.

  • 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 :lol: I sort the JS side of it out.

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

  • 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.

  • 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. :lol:

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.