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.

Javascript validation

Featured Replies

Hi,

 

I am looking for a simple javascript validation script that will work on both IE and Firefox.

 

All I really need to do is check if certain fields are empty (I'm not to fussed about correct email etc.) And I guess use an alertbox to inform the user

 

My form looks like this:

 

<form action="contact.php" method="post">

<p><label>*Name:</label> <input type="text" name="name" size="20" maxlength="40" /></p>

<p><label>*Email:</label> <input type="text" name="email" size="20" maxlength="40" /></p>

<p><label>Subject:</label> <input type="text" name="sub" size="20" maxlength="40" /></p>

<p><label>*Message:</label><br/>
<textarea cols="25" rows="10" name="body"></textarea></p>

<p class="submit"> <input type="submit" name="submit" value="Send"/></p>

<p><input type="hidden" name="submitted" value="TRUE"/></p>

</form>

 

It's ultimately only the name, email and message boxes that need to be validated.

 

Any help would be much appreciated!

Hey scaz,

 

I'd recommend the jQuery validation plugin if you want a quick and easy way to validate a form with Javascript. You could actually validate the entire form with only a few lines of Javascript with this method :)

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.