Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Apr 2010
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to bypass fields that have required validation to go to next page

    I want to show required validator when Contract is selected on this toggle.

    Code:
    <label for="exampleNASAControlNumber">Is this a Contract or Solicitation?:</label>
    		  <label class="switch2">
    				<input class="switch-input2" type="checkbox" id="contractselection" name="contractselection" runat="server"/>
    				  <span class="switch-label2" data-on="Solicitation" data-off="Contract"  id="span2" runat="server"></span>
    				  <span class="switch-handle2"></span>
    			 </label>

    The validation should work for this only when contract is selected:

    Code:
    <label for="exampleStartDate" style="position:relative; right:17px;">Contract Start Period:<span style="color:red">*</span>:</label> 
    			  <div class="bootstrap-iso"> 
    				<div class="row">   
    				 <div class=" zero-padding-left">
    				  <div class="input-group">
    				 <div class="input-group-addon">
    				   <i class="fa fa-calendar">
    				   </i>
    				</div> 
    		<input class="form-control" id="contractstartdate"  name="contractstartdate" runat="server" placeholder="MM/DD/YYYY" type="text" style="width:240px;"/>
                      </div>
                         <asp:RequiredFieldValidator ID="RequiredFieldValidator6"  ForeColor="Red"  runat="server" ControlToValidate ="contractstartdate" ErrorMessage="Please select a Contract Start Period">   
    				</asp:RequiredFieldValidator>

    and disabled for this validator:

    Code:
    <label for="exampleStartDate" style="position:relative; right:15px;">Solicitation Start Period:<span style="color:red">*</span>:</label>
    			<%--<SharePoint:DateTimeControl ID="SolicitationStartDateControl" runat="server" CssClassTextBox="form-control" DateOnly="True" />--%>
    			  <div class="bootstrap-iso"> 
    				  
    				 <div class="input-group" style="position:relative; right:15px; width:296px;">
    				 <div class="input-group-addon">
    				   <i class="fa fa-calendar">
    				   </i>
    				</div>
    				 <input class="form-control" id="solicitationstartdate" name="solicitationstartdate" runat="server" placeholder="MM/DD/YYYY" type="text"/>
                     </div>
                      <asp:RequiredFieldValidator ID="RequiredFieldValidator8"  ForeColor="Red"  runat="server" ControlToValidate ="solicitationstartdate" ErrorMessage="Please select a Solicitation Start Period">   
    				</asp:RequiredFieldValidator>
    The reverse of this when Solicitation is selected, the Contract Start Date validator should be disable and the Solicitation Start Date validator is enabled.

    How do I do this?

  2. #2
    Regular Coder
    Join Date
    Sep 2014
    Posts
    191
    Thanks
    0
    Thanked 34 Times in 32 Posts
    Try 'onclick' event on 'contractselection' checkbox. You already have an runat="server". From there, you can disable/enable your input fields.

  3. #3
    New Coder
    Join Date
    Apr 2010
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by josephm View Post
    Try 'onclick' event on 'contractselection' checkbox. You already have an runat="server". From there, you can disable/enable your input fields.
    I still need help with this. I can't do an onclick even on contractselection. It is a toggle switch. I've tried enabling and disabling using if contractselection.checked but that doesn't work either because the validators are firing off and not recognizing that condition. I'm also only using one button to validate on click. I know in some situations you can use ValidatorGroup for each validator but that only seems to work when you have multiple buttons. Does someone have any ideas on this.

  4. #4
    Regular Coder
    Join Date
    Sep 2014
    Posts
    191
    Thanks
    0
    Thanked 34 Times in 32 Posts
    Not quite sure what language you are using, or what exactly you want to achieve. I'll just show you a sample code (C#) which I wrote I wrote eons ago. The idea is if the geolocation toggle switch gets toggled, the geolocation field is either hidden or displayed.

    Code:
        <asp:CheckBox runat="server" ID="ckAllowModifyOfGeoLocation" Text="" AutoPostBack=true   OnCheckedChanged="OnckAllowModifyOfGeoLocationOnCheckedChanged" />
       <span>Manually enter Geolocation</span>
       <br />
       <br />
    	<div id="divGeolocation" runat="server">
    			<div class='form-col' ID="divLatitude" runat="server">
    				<div class='field-name'>Latitude</div>
    				<div class='field-input-short'><asp:TextBox ID="txtLatitude" runat="server" MaxLength="20"></asp:TextBox></div>	
    			</div>
    			<div class='form-col' ID="divLongtitude" runat="server">
    				<div class='field-name'>Longitude</div>
    				<div class='field-input-short'><asp:TextBox ID="txtLongitude" runat="server" MaxLength="20"></asp:TextBox></div>	
    			</div>
    
    			<div style='float:left;margin-top:5px;'>
    				<asp:Button runat="server" ID="btnReloadGeoLocation" OnClick="OnReloadGeoLocation" Text="Reload saved Longitude/Latitude" Width="300px"/>
    			</div>
    			<br />
    			<br />
    			<br />
    			<div style='float:left;margin-top:2px;'>
    				<asp:Button runat="server" ID="btnComputeGeoLocation" OnClick="OnComputeGeoLocation" Text="Determine Geolocation using specified address" Width="300px"/>
    			</div>
    			<br />
    		</div>
    This is the code behind (C#)

    Code:
    protected void OnckAllowModifyOfGeoLocationOnCheckedChanged(object sender, EventArgs e)
    {
            divGeolocation.Visible = ckAllowModifyOfGeoLocation.Checked;
    }
    Last edited by josephm; 12-17-2016 at 01:46 AM.


 

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
  •