• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Javascript noob question

 
Marc Luzietti
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Christian Gross
Author
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Kj Reddy
Ranch Hand
Posts: 1704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic