Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What kind of object is: document.getElementById("userBirthday").date

Status
Not open for further replies.

jacksondorado

IS-IT--Management
Apr 12, 2001
135
US
I am having trouble debugging a form. I want to change the birthday form field from a text field to three dropdowns for month, day, year.

To sum up:

HOW can I equate:

var bdayin = document.getElementById("userBirthday");
var bdaydate = neuro_parseDate(bdayin.value);


with

var bdayin = document.getElementById("Month").value + "/" + document.getElementById("Date").value + "/" + document.getElementById("FullYear").value;
var bdaydate = neuro_parseDate(bdayin);


DETAILS:

I keep getting errors about the object type. The

document.getElementById("txtBirthday").date

is the object type it reads currently.

I tried to create the same variable with

document.getElementById("Month").value + "/" + document.getElementById("Date").value + "/" + document.getElementById("FullYear").value

but it doesn't seem to work. Can someone tell me what .date means at the end of the variable? Also, does a text field element object have any properties before using .value to get the value?
 
It means that the object with the ID txtBirthday, probably a text input, has an attribute named date, something like:

Code:
<input type="text" id="txtBirthday" name="txtBirthday" date="somedate">

If you're getting an error with that code, it's most likely because either the text input doesn't exist or the attribute date doesn't exist.

If you want the value of a text input, using .value is the way to obtain that.

Lee
 
in addition...

but it doesn't seem to work.

what happens? have you tried creating a date object from the string you concatenate?

Code:
var myDateString = document.getElementById("Month").value + "/" + document.getElementById("Date").value + "/" + document.getElementById("FullYear").value;
var myDateObj = new Date(myDateString);
alert(myDateObj);



*cLFlaVA
----------------------------
[tt]"quote goes here"[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Thanks for the help. Creating a date object worked. It was confusing because there are at least 5 different validation functions in different javascript files- old enough?, object exists, is a valid date?, etc.

One of the functions required a date object while the others just used a string object. I just tried changing the value to a date object one at a time for each function until I found the right one.

THANKS!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top