a trouble with validate server control??

Discussion in 'ASP.NET / ASP.NET Core' started by cool_man77, Aug 24, 2004.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. I had a server form like this:

    <form runat=server>
    Username <asp:textbox id='txtUN' runat='server'>

    Password <asp:textbox id='txtPSW' runat='server'>

    FirstName <asp:textbox id='txtFN' runat='server'>

    LastName <asp:textbox id='txtLN' runat='server'>

    <asp:button id='cmdSubmit' runat=server>
    </form>

    I want to check this form with these rule:
    - force require Username & Password
    - If specify FirstName -> require LastName

    I try to make validate:

    <form runat=server>
    Username <asp:textbox id='txtUN' runat='server'>
    <asp:requiredfieldvalidator ControlToValidate="txtUN" runat="server" Text=" specify username"/>

    Password <asp:textbox id='txtPSW' runat='server'>
    <asp:requiredfieldvalidator ControlToValidate="txtPSW" runat="server" Text=" specify password"/>

    FirstName <asp:textbox id='txtFN' runat='server'>

    LastName <asp:textbox id='txtLN' runat='server'>

    <asp:button id='cmdSubmit' runat=server>
    </form>

    Anyone can help me to validate "If specify FirstName -> require LastName"??

    Thanks very much!
     
  2. I would:

    1. Create a CustomValidator control.
    2. Set ControToValidate as txtFN so that if text is entered it will run a custom function.
    3. Create a custom client-side (javascript) function that checks whether txtLN is blank. Return 0 if blank.
    4. Set ClientValidationFunction as your custom function.
     
  3. Can you show me the detail, please...
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page