Enflow
asked on
ASP.net How pass clientID to jScript in textbox onblur event
ASP.net textbox onblur JS function... Need to grab textbox ID and send it to function rather than hardcode the ID in the param pass for each input object
So have this and it works with hard code name of textbox id...
onblur="CheckEnteredDate(t his,'CBirt hDate_1'); "
would i use <% %> ??
for this function..
So have this and it works with hard code name of textbox id...
onblur="CheckEnteredDate(t
would i use <% %> ??
for this function..
function CheckEnteredDate(passed, myID) {
//alert("This is my input value = " + myID);
if (new Date(passed.value) > new Date()) {
alert('STOP - The Birth Date You Entered Is Greater Than Today!');
document.getElementById(myID).value = "";
return false;
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Add ClientIDMode="Static" to asp:Textbox control.
ASKER
@JCGD...
Why Add and Why Static... JS is working... ?
Why Add and Why Static... JS is working... ?
asp:TextBox has the ClientIDMode attribute to modify the way the ID is named. The "Static" value indicates that ASP do not change the value of the ID. Therefore, in the CheckEnteredDate you could have used getElementById("CBirthdate _1").value .
But the solution I think so is better
But the solution I think so is better
Open in new window