|
-
Jun 27th, 2005, 10:02 PM
#1
Thread Starter
Frenzied Member
Validator Postback
I have 2 text boxes (username and password) on a login form each associated with a required field validator. I also have a custom validator control which I call the ServerValidate event to authenticate.
My problem is that the form does not post back to the server until both of the required field validators are valid. Even if I put JavaScript into my HTML to set the focus to the username or password field, it does not execute unless the form is posted back.
eg.If the user enters a username but no password, the focus is not set to the password text box as the password required field validator blocks post back.
How can I force the form to post back each time a validator executes? I have set runat="Server".
-
Jun 28th, 2005, 02:28 AM
#2
Re: Validator Postback
Try setting enableclientscript property to false and handle its event in the postback
-
Jun 28th, 2005, 02:48 AM
#3
Hyperactive Member
Re: Validator Postback
 Originally Posted by robertx
I have 2 text boxes (username and password) on a login form each associated with a required field validator. I also have a custom validator control which I call the ServerValidate event to authenticate.
My problem is that the form does not post back to the server until both of the required field validators are valid. Even if I put JavaScript into my HTML to set the focus to the username or password field, it does not execute unless the form is posted back.
eg.If the user enters a username but no password, the focus is not set to the password text box as the password required field validator blocks post back.
How can I force the form to post back each time a validator executes? I have set runat="Server".
Why do you want to postback if all required fields are not filled in?
-
Jun 28th, 2005, 03:00 AM
#4
Thread Starter
Frenzied Member
Re: Validator Postback
Because I want to set focus to the field that is missing data and I can only do it using JavaScript which is only called if the page is reloaded.
Mendhak - that worked perfectly.
I set enableclientscript = false for the 2 required field validator controls and put the following JavaScript into the HTML:
Code:
<SCRIPT language="javascript">var myForm = document.Form1;if (myForm.txtUserName.value == ""){myForm.txtUserName.focus();myForm.txtUserName.select();} else {myForm.txtPassword.focus();myForm.txtPassword.select();}</SCRIPT>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|