Results 1 to 4 of 4

Thread: Validator Postback

Hybrid View

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2001
    Posts
    1,374

    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".

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Validator Postback

    Try setting enableclientscript property to false and handle its event in the postback

  3. #3
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479

    Re: Validator Postback

    Quote 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?

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2001
    Posts
    1,374

    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
  •  



Click Here to Expand Forum to Full Width