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

URGENT :: How to get form variable's value in javascript function ?

Status
Not open for further replies.

snr

Programmer
Oct 8, 2001
78
0
0
US
Hi ,
I want to use javascript for some simple client side validations, like if there are 2 textboexes, and if I write in second textbox, & first textbox is null , I want to give alert that first textbox value is null and the focus should be transfered to first textbox.
For this I need to know how to access value of form item in javascript, for which I used to write
document.form1.textbox1.value
in ASP.
I want equivalent for this statement.

Thanks ...

 
If you are writing javascript to complete the task why would you change that at all? Maybe I am not understanding your question but if you want to do javascript checking you should use javascript syntax.

You will have other considerations to make though, because you will need to consider how your page submits. With Asp.Net the default is for the page to submit to itself, if you want to control the page submission through javascript you may need to work around the default method.

Otherwise you could use server side validation and just do it in a custom fashion. So in your code behind do the checks you want to do then you could write some javascript to the page that will cause the focus to go where it should etc (I personally use a literal control when I want to put in dynamically created javascript code).

I don't know if this is much help but maybe it will give you a starting point. Crystal
crystalized_s@yahoo.com

--------------------------------------------------

Experience is one thing you can't get for nothing.

-Oscar Wilde

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top