Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
JavaScript - Date Validation
Old 12-01-2004, 01:49 PM JavaScript - Date Validation
Experienced Talker

Posts: 45
Trades: 0
I have 3 date fields in a form (month, day, year). The 'month' field is a drop down menu as well as the 'day' field. The 'year' field is a text box.

The respective field id's are the same names.

Basically, I need to add some JavaScript that would prevent a user from submitting the form if he or she inputted a date in the above fields that was within 31 days of the current day. Anything outside of 31 days is okay. I don't want the error message to be returned upon entering the date, I need it to be returned when they try to use the submit button, because I'm using in page error messaging.

How can I tell these 3 fields to verify the current date against the entered date, and if it's 31 days or less, send back an in page error message, if it's over 31 days than the form would submit.

Thanks
Jacob
planeboy7e7 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-04-2004, 11:37 AM
Rufo's Avatar
Extreme Talker

Posts: 173
Trades: 0
You'd want to do it with a server side scripting language such as PHP, or it could be circumvemted by changing the system clock.
A couple of if() statements should do the trick.

Rufo.
__________________

Please login or register to view this content. Registration is FREE
Rufo is offline
Reply With Quote
View Public Profile Visit Rufo's homepage!
 
Old 12-04-2004, 04:53 PM
Average Talker

Posts: 21
Trades: 0
I agree with Rufo. Client-side Javascript will be convenient because you can instantly check the validity of the fields without loading a new page. But don't let your server rely on client-side security measures. It's a trivial task for someone with malicious intentions to submit any info they want to the server. JS is convenient, but not secure.

If you still want to use JS, just read up on how to read the form data and how to read the date on the system clock, then compare the two dates. If you want to check it when they click submit, use the onSubmit() method in the form tag. I'm a little rusty on my JS, but maybe that can get you started.
Ah46 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to JavaScript - Date Validation
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.11451 seconds with 12 queries