JavaScript Problem
Respected Sir,
i seem to be having quite a problem trying to validate my asp.net webform...using javascript....My webform contains 2 textboxes and a button which is used to submit the form. (both the textboxes and button are webcontrols).... everytime i click the submit button i have called a javascript function in the aspx page using btn.Attributers.Add("onclick","functionName") ...if initially the txtboxes are empty...an alert is raised when i click the btn....which is what it shoul be doing....now if i fill both the textboxes after that and i click the button i still get the alert ...only if i click the button twice the alert goes away.... please could u tell me what the problem is...and give me a little advise on what i should do...the code that i have written is somethin like this
codebehind:(C#)
//let btn be button
//txt1 be textbox1
// txt2 be textbox2
private void Page_Load(Object sender,EventArgs e)
{
this.btn.Attributes.Add("onclick","validateFor m()");
}
protected void btn_Clicked(Object sender,EventArgs e)
{
if(txt1.Text==""||txt2.Text=="")
{
string incompleteForm="<script>" +
"alert('Incomplete From')" +
"</script>"
}
else
{
//connectToDatabase
}
}
achhetri
__________________
achhetri
|