Java Script Validation

H

hoz

Hi ,
I am developing an web application . I have a form for user login ,contains
two textboxs . How can i check them if these are empty using client side
validation ?
But i want it like below
<script lang="..... >
function Validate()
{ if ( this.forms.userTxt=="")
return false ;
....
}
</script>

the button is server side , how can i add , when clicked first goto Validate
and then execute button_click() ?
 
S

Shiva

Button.Attributes.Add ("onClick", "return Validate();")

Your Validate() function should return true if postback should occur, false
to stay.

Another option is to use the RequiredFieldValidator control (one for each
text box).

Hi ,
I am developing an web application . I have a form for user login ,contains
two textboxs . How can i check them if these are empty using client side
validation ?
But i want it like below
<script lang="..... >
function Validate()
{ if ( this.forms.userTxt=="")
return false ;
....
}
</script>

the button is server side , how can i add , when clicked first goto Validate
and then execute button_click() ?
 
M

Matt Berther

Hello hoz,

Look at the asp:RequiredFieldValidator control. This handles everything for
you. You dont need to write any javascript.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top