aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Javascript noob question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Javascript noob question" Watch "Javascript noob question" New topic
Author

Javascript noob question

Marc Luzietti
Ranch Hand

Joined: Feb 02, 2006
Posts: 84
I grabbed a script from http://www.quirksmode.org/js/datecheck.html
It's based on dropdowns. I want it to check text boxes instead.

How would I change
var day = parseInt(x[name+"_DD"].options[x[name+"_day"].selectedIndex].value);
in order to do this?


Support Kathy Sierra
Christian Gross
Author
Ranch Hand

Joined: Feb 20, 2006
Posts: 85
If you have three text boxes, then they would be parsed as follows.

var day = parseInt( document.getElementById( "day").value);
var month = parseInt( document.getElementById( "month").value);
var year = parseInt( document.getElementById( "year").value);

The only field where you will have a problem is month because month is displayed as Jan, Feb, etc, but the values are 1, 2, 3. So you will have to create a lookup table.

Christian


Author of Ajax Patterns and Best Practices
Kj Reddy
Ranch Hand

Joined: Sep 20, 2003
Posts: 1704
Originally posted by Marc Luzietti:
I grabbed a script from http://www.quirksmode.org/js/datecheck.html
It's based on dropdowns. I want it to check text boxes instead.

How would I change
var day = parseInt(x[name+"_DD"].options[x[name+"_day"].selectedIndex].value);
in order to do this?


Do you want read values from text box? If yes:

var day = parseInt(document.formname.textboxname.value);

replace formname and textboxname with your form and text box names
Marc Luzietti
Ranch Hand

Joined: Feb 02, 2006
Posts: 84
Shoulda mentioned, I can't do a getByElementID (or Name for that matter). I have to check several different pages, and I cannot set the ID/Name (thanks netui ). Also, on one of the pages, there will be multiple sets of dates, so I'll have to write a loop.

I could use Prototype to getByClassName I think, but this would still cause me trouble on the page with the multiple dates.



I'm really going beyond my skills at this point, so I'm really unsure of how to procede . . . but that's how we grow.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Javascript noob question
 
Similar Threads
location of a JS in frame
Popup window not working
this.title returning undefined
Doubt in JQuery
offsetWidth problem