This is a migrated thread and some comments may be shown as answers.

Disabling validation on Previous button click

3 Answers 106 Views
Wizard
This is a migrated thread and some comments may be shown as answers.
Bill
Top achievements
Rank 1
Bill asked on 03 Nov 2016, 10:49 PM

 

Is there a way to disable validation when the previous button or a navbar button < current step is clicked?

3 Answers, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 08 Nov 2016, 02:45 PM
Hello Bill,

By design the validation is not triggered when clicking the Step's Previous button. Consider the following example:
‚Äč
<telerik:RadWizard RenderMode="Lightweight" ID="RadWizard1" runat="server">
    <WizardSteps>
        <telerik:RadWizardStep ID="RadWizardStep1" Title="FirstStep" runat="server" StepType="Step" ValidationGroup="personalInfo">
            Step1
        </telerik:RadWizardStep>
        <telerik:RadWizardStep ID="RadWizardStep2" Title="SecondStep" ValidationGroup="personalInfo" CausesValidation="true">
            Step2
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
            <asp:RequiredFieldValidator ID="TextBox1RequiredFieldValidator1" runat="server"
                ControlToValidate="TextBox1" EnableClientScript="true" ValidationGroup="personalInfo" ErrorMessage="required field"
                CssClass="validator" ForeColor="Red"></asp:RequiredFieldValidator>
        </telerik:RadWizardStep>
        <telerik:RadWizardStep ID="RadWizardStep3" Title="ThirdStep" runat="server" StepType="Step">
            Step3
        </telerik:RadWizardStep>
    </WizardSteps>
</telerik:RadWizard>

In Step 2 the TextBox' validation is triggered if you press the Next button without entering text, but you can freely navigate back to Step 1, both through clicking the Previous button or the navbar.

Regards,
Ivan Danchev
Telerik by Progress
Check out the new UI for ASP.NET Core, the most complete UI suite for ASP.NET Core development on the market, with 60+ tried-and-tested widgets, based on Kendo UI.
0
Bill
Top achievements
Rank 1
answered on 08 Nov 2016, 08:11 PM

Well Ivan it may not be enabled by design but it sure seems to be enabled (I'm good at enabling stuff I'm not supposed to). Here's the code, all of the steps are not completed yet but what's there works. Here's the thing - complete step 1, hit Next, no problemo. From step 2 (with validation errors) click next, won't go and displays the little red stars like I told it to. So far so good. Now click Previous and the same thing happens, stays on the current step (2) and displays the validation error strings. grrrrrrr.

 

<telerik:RadWizard RenderMode="Lightweight" runat="server" ID="RadWizard1"
        OnPreviousButtonClick="RadWizard1_PreviousButtonClick"
        OnNavigationBarButtonClick="RadWizard1_NavigationBarButtonClick"
        OnActiveStepChanged="RadWizard1_ActiveStepChanged"
        OnClientButtonClicking="OnClientButtonClicking"
        OnFinishButtonClick="RadWizard1_FinishButtonClick">
    <WizardSteps>
        <telerik:RadWizardStep ID="RadWizardStep1"
                Title="Select a Shipment"
                StepType="Start"
                ValidationGroup="Step1"
                ActiveImageUrl="images/1_active.png"
                ImageUrl="images/1_normal.png">
            <div class="instructions">
                <span>Please select a shipment and click <i>Next</i> to proceed.</span>
            </div>
            <br />
            <asp:RequiredFieldValidator runat="server" id="RequiredFieldValidator1"
                    ControlToValidate="cmbShipment"
                    ValidationGroup="Step1"
                    Text="*" ForeColor="Red"
                    Display="Dynamic" />
            <telerik:RadComboBox RenderMode="Lightweight" ID="cmbShipment" runat="server"
                    Label="Select a Shipment"
                    Width="500px" Height="400px"
                    EmptyMessage="Select"
                    DataSourceID="SqlDataSource1"
                    DataTextField="Chop_Mark"
                    DataValueField="Shipment_ID"
                    CssClass="rdfFieldValue" >
            </telerik:RadComboBox>
        </telerik:RadWizardStep>
        <telerik:RadWizardStep ID="RadWizardStep2"
                Title="Enter Cupping Details"
                ValidationGroup="Step2"
                ActiveImageUrl="images/2_active.png"
                ImageUrl="images/2_normal.png">
            <div class="instructions">
                <p><telerik:RadLabel RenderMode="Lightweight" runat="server" ID="txtCupping" Text="Cupping is not required for this shipment!" Font-Size="1em" ForeColor="Red" ReadOnly="true" /> </p>
                <p>Enter the cupping info below and click <i>Next</i> to proceed.</p>
                <table class="first">
                    <tr>
                        <td>Sample Logged 
                            <asp:RequiredFieldValidator runat="server" ID="SampleLoggedValidator"
                                ControlToValidate="SampleLogged"
                                ValidationGroup="Step2"
                                Text="*" ForeColor="Red"
                                Display="Dynamic" />
                        </td>
                        <td><telerik:RadDateTimePicker RenderMode="Lightweight" runat="server" ID="SampleLogged" ToolTip="Enter date sample was logged" Width="500px"></telerik:RadDateTimePicker></td>
                    </tr>
                    <tr>
                        <td>Sample Taken 
                            <asp:RequiredFieldValidator runat="server" ID="SampleTakenValidator"
                                ControlToValidate="SampleTaken"
                                ValidationGroup="Step2"
                                Text="*" ForeColor="Red"
                                Display="Dynamic" />
                        </td>
                        <td><telerik:RadDateTimePicker RenderMode="Lightweight" runat="server" ID="SampleTaken" ToolTip="Enter date sample taken" Width="500px"></telerik:RadDateTimePicker></td>
                    </tr>
                    <tr>
                        <td>Cupping Date 
                            <asp:RequiredFieldValidator runat="server" ID="CuppingDateValidator"
                                ControlToValidate="CuppingDate"
                                ValidationGroup="Step2"
                                Text="*" ForeColor="Red"
                                Display="Dynamic" />
                        </td>
                        <td>
                            <telerik:RadDateTimePicker RenderMode="Lightweight" runat="server"
                                ID="CuppingDate" ToolTip="Enter date of cupping" Width="500px" />
                        </td>
                    </tr>
                </table>
                <table>
                    <tr>
                        <td>
                            <asp:RequiredFieldValidator runat="server" ID="ContainerNbrValidator"
                                ControlToValidate="ContainerNbr"
                                ValidationGroup="Step2"
                                Text="*" ForeColor="Red"
                                Display="Dynamic" />
                            <telerik:RadTextBox RenderMode="Lightweight" runat="server"
                                ID="ContainerNbr" ToolTip="Enter the Container number" ValidationGroup="Step2"
                                Label="Container #" LabelWidth="120px" Width="500px" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:RequiredFieldValidator runat="server" ID="CargoNbrValidator"
                                ControlToValidate="CargoNbr"
                                ValidationGroup="Step2"
                                Text="*" ForeColor="Red"
                                Display="Dynamic" />
                            <telerik:RadTextBox RenderMode="Lightweight" runat="server"
                                ID="CargoNbr" ToolTip="Enter the Cargo number" ValidationGroup="Step2"
                                Label="Cargo #" LabelWidth="120px" Width="500px" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <telerik:RadTextBox RenderMode="Lightweight" runat="server"
                                ID="ReferenceNbr" ToolTip="Enter the Reference number"
                                Label="Reference #" LabelWidth="120px" Width="500px" />
                        </td>
                    </tr>
                </table>
                <br />
                <br />
                <table>
                    <tr>
                        <td>
                            <asp:RequiredFieldValidator runat="server" id="NewStatusValidator"
                                    ControlToValidate="cmbNewStatus"
                                    ValidationGroup="Step2"
                                    Text="*" ForeColor="Red"
                                    Display="Dynamic" />
                            <telerik:RadComboBox RenderMode="Lightweight" ID="cmbNewStatus" runat="server"
                                    Label="Choose New Status"
                                    Width="400px" Height="200px"
                                    EmptyMessage="Select"
                                    DataSourceID="SqlDataSource3"
                                    DataTextField="Name"
                                    DataValueField="Shipment_Status_ID"
                                    CssClass="rdfFieldValue"
                                    AutoPostBack="true"
                                    OnSelectedIndexChanged="cmbNewStatus_SelectedIndexChanged">
                            </telerik:RadComboBox>
                        </td>
                        <td>
                            <asp:RequiredFieldValidator runat="server" id="ReasonsValidator"
                                    ControlToValidate="cmbReasons"
                                    ValidationGroup="Step2"
                                    Text="*" ForeColor="Red"
                                    Display="Dynamic" />
                            <telerik:RadComboBox RenderMode="Lightweight" ID="cmbReasons" runat="server"
                                    Label="Select a Reason"
                                    Width="400px" Height="200px"
                                    EmptyMessage="Select"
                                    DataSourceID="SqlDataSource4"
                                    DataTextField="Name"
                                    DataValueField="Reason_Code_ID"
                                    CssClass="rdfFieldValue" >
                            </telerik:RadComboBox>
                        </td>
                    </tr>
                </table>
            </div>
        </telerik:RadWizardStep>
        <telerik:RadWizardStep ID="RadWizardStep3"
                Title="Update Shipment Status"
                ValidationGroup="Step3"
                ActiveImageUrl="images/3_active.png"
                ImageUrl="images/3_normal.png">
            <telerik:RadTextBox RenderMode="Lightweight" runat="server" ID="RadTextBox13" ToolTip="Q4" Label="Share a good point." LabelWidth="200px" Width="600px"></telerik:RadTextBox>
            <br />
            <telerik:RadTextBox RenderMode="Lightweight" runat="server" ID="RadTextBox14" ToolTip="Q5" Label="Share a good point." LabelWidth="200px" Width="600px"></telerik:RadTextBox>
            <br />
            <telerik:RadTextBox RenderMode="Lightweight" runat="server" ID="RadTextBox15" ToolTip="Q6" Label="Share a good point." LabelWidth="200px" Width="600px"></telerik:RadTextBox>
        </telerik:RadWizardStep>
        <telerik:RadWizardStep ID="RadWizardStep4" Title="Confirm" StepType="Finish">
            <telerik:RadTextBox RenderMode="Lightweight" runat="server" ID="RadTextBox16" ToolTip="Q7" Label="Share a bad point." LabelWidth="200px" Width="600px"></telerik:RadTextBox>
            <br />
            <telerik:RadTextBox RenderMode="Lightweight" runat="server" ID="RadTextBox17" ToolTip="Q8" Label="Share a bad point." LabelWidth="200px" Width="600px"></telerik:RadTextBox>
            <br />
            <telerik:RadTextBox RenderMode="Lightweight" runat="server" ID="RadTextBox18" ToolTip="Q9" Label="Share a bad point." LabelWidth="200px" Width="600px"></telerik:RadTextBox>
            <br />
            <asp:Label runat="server" CssClass="finishNote" Text="Press Finish to close RadWindow"></asp:Label>
        </telerik:RadWizardStep>
    </WizardSteps>
</telerik:RadWizard>


0
Ivan Danchev
Telerik team
answered on 10 Nov 2016, 02:41 PM
Hello Bill,

I checked how your Wizard behaves and the reason for the validation firing when navigating back from the second step back to the first one is because they have different ValidationGroup set (Step1 and Step2). As stated in the documentation article I linked in my previous reply you need to set the same ValidationGroup if you want to navigate between them without the validation firing. So I set ValidationGroup ="Step1" to the second step itself and to the RequieredFieldValidators it contains and the validation did not fire when navigating back to the "Select a Shipment" step.

Regards,
Ivan Danchev
Telerik by Progress
Check out the new UI for ASP.NET Core, the most complete UI suite for ASP.NET Core development on the market, with 60+ tried-and-tested widgets, based on Kendo UI.
Tags
Wizard
Asked by
Bill
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
Bill
Top achievements
Rank 1
Share this question
or