I want to execute javascript BEFORE validation

Last post 05-09-2008 5:41 AM by pr200008. 3 replies.

Sort Posts:

  • I want to execute javascript BEFORE validation

    05-08-2008, 1:14 PM
    • Loading...
    • pr200008
    • Joined on 12-08-2006, 2:22 PM
    • Posts 22

    Hi, I'm trying to persist a full local file path selected in a fileupload control as it doesn't persist (I understand why) across postbacks. I am using a req field validator. If the page posts back for some reason (there are valid scenarios) I don't want the user to have to choose the same file over again. 

    When the page postsback, I want to execute a client-side javascript BEFORE the client-side page validation occurs. If my hidden field used to persist the file path is populated, I want to disable the required field validator on the fileupload control. I looked to see if I could use the req field validator on the hidden field but it doesn't seem as if I can. At this point it seems the validation occurs before my script is executed client-side. I know this sounds messy, any other suggested approaches are welcome. Any hints on how to do this?

     Thanks

    Thanks
    PR
  • Re: I want to execute javascript BEFORE validation

    05-08-2008, 2:10 PM
    • Loading...
    • RyanCreek
    • Joined on 05-06-2008, 5:33 PM
    • Posts 18

     Test on event, if your hidden field has a value just disable your requiredfieldvalidator.  On load, or postback, or whatever you're trying to accomplish.

     Do you have viewstate disabled? All my form fields retain their values on postback unless I specifically clear them with viewstate enabled.

     

    Brandon
     

  • Re: I want to execute javascript BEFORE validation

    05-08-2008, 2:11 PM
    Answer

    I wrote an article on my blog about conditional validation.  Please take a look.

    http://www.dotnetadvisor.com/Blog/ConditionalValidation.aspx
     

  • Re: I want to execute javascript BEFORE validation

    05-09-2008, 5:41 AM
    • Loading...
    • pr200008
    • Joined on 12-08-2006, 2:22 PM
    • Posts 22

    Cheers Rob, I'll work through this.

    Thanks
    PR
Page 1 of 1 (4 items)