JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 30th, 2001, 03:15 PM
appletreats appletreats is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2001
Posts: 2 appletreats User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question JavaScript: Form field error checking

I have a page which contains an HTML form. When the user clicks the submit button, I want to check to make sure that all of the form fields have been filled in. I also want to check that certain fields contain no letters, that certain fields contain no numbers, and that the email field is in the form a@b.c If there is a problem, a box should pop up asking the user to fix the problems. If everything is fine, things should continue normally (as if there was no javascript). How can I do this?

Reply With Quote
  #2  
Old November 30th, 2001, 03:24 PM
Rachelmnms Rachelmnms is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2001
Location: Seattle, WA
Posts: 18 Rachelmnms User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Cool Try this . .

Go to this link and do a find in the page for "validation". There are MANY examples of how to do it from dates, to characters, to email addresses. Takes a minute to load, but well worth it as a reference and to "code reuse". ;-) It's free.

Rachel


http://javascript.internet.com/mast...aster-list.html

Reply With Quote
  #3  
Old November 30th, 2001, 03:32 PM
appletreats appletreats is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2001
Posts: 2 appletreats User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Very helpful, thanks!

Reply With Quote
  #4  
Old May 14th, 2013, 07:49 PM
me10lee83 me10lee83 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2013
Posts: 31 me10lee83 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 47 m 47 sec
Reputation Power: 1
I got the validation working thanks to the link above but would like to expand what it checks for and am having some trouble doing this.

It currently checks the values are within a set range and display particular error messages if not (depending on its too high, too low, or empty). I would also like it to check that the value is actually a number. I tried using isNaN but it's not working.

Also, I would like the calculation to occur ONLY if all the fields pass. I tried using an if statement to check if the function is true (and the validate function returns true or false based on the result) but it doesn't work.

Here are a link to the files
http://tiger.towson.edu/~tbaldw2/loan_calculator/LoanCalc.html
http://tiger.towson.edu/~tbaldw2/loan_calculator/LoanCalc.js
(working files)

http://tiger.towson.edu/~tbaldw2/loan_calculator/LoanCalc1.html
http://tiger.towson.edu/~tbaldw2/loan_calculator/LoanCalc1.js (with the non-working changes)

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > JavaScript: Form field error checking

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap