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

finding my textbox value

Status
Not open for further replies.

dembyg

Programmer
Oct 20, 2001
58
US

I wonder if someone could help with my problem. I wrote a javascript function CheckIfLoginExpired.. This function is suppose to return the value of a text field called loginName however there seems to be something wrong with my function which ive used in an older version of asp.net


function CheckIfLoginExpired()
{
var logtext = LoginName.value;
if ((logtext == null) || (logtext == ""))
{
alert("Login Expired"+logtext) ;
}
}

thanks for any help you can provide
 
So you want to alert the value of logtext when it's equal to null or equal to the null string?

If it is supposed to return a value, then you need a return statement in the function.

Also, make sure you have a text field in your HTML that has name="LoginName".

[monkey][snake] <.
 
Thanks for your response. The text field is in my html which has the name LoginName. however when i try running the code i get an error that 'LoginName' is undefined.
 
its probably because it can't get the field, try something like :

var logtext = document.getElementById("LoginName").value;

if that does not work, please post the HTML source of the output page from the .Net.

Greg Griffiths
Livelink Certified Developer & ECM Global Star Champion 2005 & 2006
 
You need to ensure when you view the [!]client-side source[/!] (Which is not the same as the ASP source) that the field has a name of "LoginName" if you want to refer to it by name:

Code:
alert(document.forms['TheRealHTMLFormName'].elements['LoginName'].value);

or an ID (again, [!]client-side[/!], not in the ASP source) of "LoginName" if you want to go down the route suggested by Greg.

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Thank you ggriffit your suggestion worked:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top