CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2002
    Location
    Mumbai
    Posts
    98

    Smile Multiple validation on the click of the submit button

    Hi all,

    I am trying to validate the multiple controls, on click of the next button on the ASP Page. (Next Button is the server control).

    In the validation of the multiple controls for example 3 textboxes

    The user can enter the value in one text box or in two or in all of them or in none of them.

    I want to validate, whether the user has entered the value in atleast one of them. And if yes, then only it should go to save the data and move to next page.

    I have tried adding the javascript through add.attribute, it works but it goes for saving the data into the database and moves to next page.

    I tried the customValidator control, but it doesnt work.

    Can anybody help me in this? I am stuck with this and cant move ahead.

    Any help will be appreciated.

    Thank You

  2. #2
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: Multiple validation on the click of the submit button

    It should be easy using JavaScript. Can you post the Javascript code that you are using?

    And what version of ASP.NET are you working on?

  3. #3
    Join Date
    Sep 2002
    Location
    Mumbai
    Posts
    98

    Smile Re: Multiple validation on the click of the submit button

    I got my mistake, i was calling javascript function only . But the way i was calling it was wrong.

    Code ::

    Initially i wrote code as ::

    btnNext.Attirbutes.Add("OnClick", "ValidateValues()")

    Where as the correct way is ::

    btnNext.Attirbutes.Add("OnClick", "return ValidateValues()")


    Thanks for your help.

    Amit

  4. #4
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: Multiple validation on the click of the submit button

    Thats what I was also suspecting that you might not be returning the true/false back from the JS function.

    Anyways, I am glad that you resolved your problem.

  5. #5
    Join Date
    Feb 2005
    Location
    Denmark
    Posts
    742

    Re: Multiple validation on the click of the submit button

    You could also overload the validator control and make your own, and then simply make your own isValid implementation. This way you can keep it to the asp.net validatiors and thus the same type of error messages et al. It is particular usefull if you have other asp:validators on the page as well, and it is relative simple for what you ask.

    This would proberly have been the way I personally would do it.

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

Featured