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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

simple getElementById question

Status
Not open for further replies.

786snow

Programmer
Nov 12, 2006
75
Hi,

I have a texbox called startdate in my HTML. How can I use variable in my document.getElementById, instead of hardcoding it. I tried the
following but it did not work, saying object required





var date= "startdate";

if ((document.getElementById('+date+').value.match(RegExPattern)) && (document.getElementById('+date+').value!='')) {
 
take out the quotes and plusses - those are used for string concatenation and are not needed for what you're doing:

Code:
if ((document.getElementById([!]date[/!]).value.match(RegExPattern)) && (document.getElementById([!]date[/!]).value!='')) {

-kaht

Looking for a puppy? [small](Silky Terriers are hypoallergenic dogs that make great indoor pets due to their lack of shedding and small size)[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top