Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Dec 2009
    Thanked 0 Times in 0 Posts

    Question Javascript Radio button that Toggles the Validation between to textbox values

    I am using ASP validators and I have a contact form. I want to be able to have a phone and email radio button group. The email textbox also has a RegularExpressionValidator

    If the phone item is selected then I want the validation to be enabled on the phone text box making it mandatory while the email text box isn't, and if they choose the email as the contact it will be reversed.

    I want to be able to do this without having to do a postback.

    I already have the logic on the code behind and the enquiry object.

    also I am fairly new to javascript so I have been using mostly jQuery as easier to implement

  2. #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Thanked 4,947 Times in 4,908 Posts
    Well, ASP.NET isn't really set up to do this, but it's easy enough to do in pure JS code as an "add-on" without ASP.NET being aware of it.

    But if you have *other* ASP.NET-driven validation taking place, then you have to figure out how to "hook in" this validation.

    If you could remove the ASP.NET RegExp validator from the <form> and then bring up the page in your browser and do a VIEW==>>SOURCE to see the HTML ASP.NET is producing and copy that here, then it would be a lot easier to try to help you. Or just show us the site live, if that's easier/possible.
    Be yourself. No one else is as qualified.


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts