Note that there are some explanatory texts on larger screens.

plurals
  1. POValidations not working
    text
    copied!<p>I have few text boxes which has required field validation. In the same page there is a back button and next button. When i click in the back button the validations are working, when i click on the next button validations are not working (means the form is moving to the next page) </p> <p>Please help me to rectify</p> <pre><code> &lt;%@ Page Language="vb" AutoEventWireup="false" CodeBehind="RequestorForm.aspx.vb" Inherits="WebApplication1.RequestorForm" %&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head id="Head1" runat="server"&gt; &lt;title&gt;Requestor Form&lt;/title&gt; &lt;link rel="stylesheet" type="text/css" href="homepage2005.css"&gt; &lt;script language="javascript" type="text/javascript"&gt; //Call Server Event on User id onblur() function CallClientEvent() { __doPostBack("txt_view1_userID_TextChanged", ""); } function CheckValidation() { Page_ClientValidate(); if (Page_IsValid) { if (CheckRoleValidation()) { if ('&lt;%=strRoleType%&gt;' == 'chkBx_Store_wu') { return CheckTeamViewerDep(); } } else { return false; } } } function CheckTeamViewerDep() { var ctl = document.getElementById('chkbx_teamLeadStockRoom'); if (ctl.disabled) { return true; } var tDiv = document.getElementById('chkDepGroup'); var chkitm = tDiv.getElementsByTagName("input"); for (var i = 0; i &lt; chkitm.length; i++) { if (chkitm[i].checked) { return true; } } var ctlvalidate = document.getElementById('span_chkDepGroup'); ctlvalidate.innerHTML = 'Please select Dep'; return false; } function CheckRoleValidation() { //var cblItm = '&lt;%=gvRoleDep%&gt;'; var tDiv = document.getElementById('gvRoleDep'); var chkitm = tDiv.getElementsByTagName("input"); var flag = false; var chkItemCount = 0; for (var i = 0; i &lt; chkitm.length; i++) { if (chkitm[i].checked) { chkItemCount++; flag = true; } } var ctlvalidate = document.getElementById('lbl_chkBx_store_wu'); if (!flag) { ctlvalidate.innerHTML = 'Please select Role(s)'; return false; } if (chkItemCount &gt; 5) { ctlvalidate.innerHTML = 'Maximum of 5 Role(s) only can be checked'; return false; } } function ValidateDropDown() { Page_ClientValidate(); flag = 1; objTOR = document.getElementById('ddl_view0_typeOfRequest'); objWUL = document.getElementById('ddl_view0_wuLevel'); if (Page_IsValid) { //alert(objTOR.selectedIndex); TOR = document.getElementById('span_ddl_view0_typeOfRequest'); WUL = document.getElementById('span_ddl_view0_wuLevel'); if (objTOR.selectedIndex == 0) { //alert('Select a value:'); TOR.innerHTML = "*Please select a Type of Request"; flag = 0; } else TOR.innerHTML = " "; // if (objWUL.selectedIndex == 0) { // WUL.innerHTML = "*Please select a W A"; // flag = 0; // } // else // WUL.innerHTML = " "; if (flag == 0) return false; return true; } } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="form1" runat="server"&gt; &lt;div style="margin-left: 10px"&gt; &lt;asp:MultiView runat="server" ID="mvRequestorForm" ActiveViewIndex="0"&gt; &lt;asp:View runat="server" ID="view_0"&gt; &lt;h1 class="blue"&gt; &lt;asp:Label ID="lbl_viewTitle0" runat="server" Text="Label"&gt;&lt;/asp:Label&gt; &lt;/h1&gt; &lt;table border="0" cellpadding="0" cellspacing="0" width="100%"&gt; &lt;tr&gt; &lt;td class="tabRow" width="150"&gt; &lt;asp:Label ID="lbl_view0_firstName" runat="server" Text="Firstname "&gt;&lt;/asp:Label&gt; &lt;/td&gt; &lt;td width="200"&gt; &lt;asp:TextBox ID="txt_firstName" runat="server" AutoCompleteType="FirstName" CssClass="text_box_3" TabIndex="1"&gt;&lt;/asp:TextBox&gt; &amp;nbsp;&lt;asp:Label ID="Label5" runat="server" ForeColor="Red" Text="*"&gt;&lt;/asp:Label&gt; &lt;/td&gt; &lt;td&gt; &lt;asp:RequiredFieldValidator ID="Validator_FirstName" runat="server" ControlToValidate="txt_firstName" ErrorMessage="* Required field" ValidationGroup="Form1"&gt;&lt;/asp:RequiredFieldValidator&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class="tabRow"&gt; &lt;asp:Label ID="lbl_view0_surname" runat="server" Text="Surname"&gt;&lt;/asp:Label&gt; &lt;/td&gt; &lt;td&gt; &lt;asp:TextBox ID="txtSurName" runat="server" AutoCompleteType="LastName" CssClass="text_box_3" TabIndex="3"&gt;&lt;/asp:TextBox&gt; &amp;nbsp;&lt;asp:Label ID="Label6" runat="server" ForeColor="Red" Text="*"&gt;&lt;/asp:Label&gt; &lt;/td&gt; &lt;td&gt; &lt;asp:RequiredFieldValidator ID="Validator_Surname" runat="server" ControlToValidate="txtSurName" ErrorMessage="* Required field" ValidationGroup="Form1"&gt;&lt;/asp:RequiredFieldValidator&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class="tabRow"&gt; &lt;asp:Label ID="lbl_view0_ContactNum" runat="server" Text="Contact number"&gt;&lt;/asp:Label&gt; &lt;/td&gt; &lt;td&gt; &lt;asp:TextBox ID="txt_contactNum" runat="server" AutoCompleteType="BusinessPhone" CssClass="text_box_3" TabIndex="3"&gt;&lt;/asp:TextBox&gt; &amp;nbsp;&lt;asp:Label ID="Label7" runat="server" ForeColor="Red" Text="*"&gt;&lt;/asp:Label&gt; &lt;/td&gt; &lt;td&gt; &lt;asp:RequiredFieldValidator ID="Validator_ContactNumber" runat="server" ControlToValidate="txt_contactNum" ErrorMessage="* Required field" ValidationGroup="Form1"&gt;&lt;/asp:RequiredFieldValidator&gt; &lt;asp:RangeValidator ID="RangeValidator1" runat="server" ControlToValidate="txt_contactNum" ErrorMessage="Enter a numeric value" MaximumValue="99999999999999" MinimumValue="0"&gt;&lt;/asp:RangeValidator&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;hr class="blue" /&gt; &lt;table border="0" cellpadding="0" cellspacing="0" width="100%"&gt; &lt;tr&gt; &lt;td class="tabRow" width="150"&gt; &lt;asp:Label ID="lbl_view0_typeOfRequest" runat="server" Text="Type of request"&gt;&lt;/asp:Label&gt; &lt;/td&gt; &lt;td width="500"&gt; &lt;asp:DropDownList ID="ddl_view0_typeOfRequest" runat="server" CssClass="drop_down_t" TabIndex="4"&gt; &lt;asp:ListItem Value="-1"&gt;Please select...&lt;/asp:ListItem&gt; &lt;asp:ListItem&gt;New&lt;/asp:ListItem&gt; &lt;asp:ListItem&gt;Update&lt;/asp:ListItem&gt; &lt;asp:ListItem&gt;Delete&lt;/asp:ListItem&gt; &lt;/asp:DropDownList&gt; &lt;span ID="span_ddl_view0_typeOfRequest" class="errorText"&gt;&lt;/span&gt; &lt;/td&gt; &lt;td&gt; &amp;nbsp; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class="tabRow"&gt; &lt;asp:Label ID="lbl_view0_wuLevel" runat="server" Text="W A"&gt;&lt;/asp:Label&gt; &lt;/td&gt; &lt;td&gt; &lt;asp:DropDownList ID="ddl_view0_wuLevel" runat="server" CssClass="drop_down_t" TabIndex="5"&gt; &lt;asp:ListItem Selected="True" Value="3"&gt;Store&lt;/asp:ListItem&gt; &lt;/asp:DropDownList&gt; &lt;span ID="span_ddl_view0_wuLevel" class="errorText"&gt; &lt;/span&gt; &lt;/td&gt; &lt;td&gt; &amp;nbsp; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&amp;nbsp;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt; &lt;/table&gt; &lt;asp:Label ID="lblCaption1" runat="server" Text="* Represents fields that needs to be filled mandatory" Font-Size="XX-Small" ForeColor="#FF3300"&gt;&lt;/asp:Label&gt; &lt;br /&gt; &lt;hr /&gt; &lt;asp:Button ID="btn_View0_Next" runat="server" OnClientClick="return ValidateDropDown();" Text="Next" ValidationGroup="Form1" /&gt; &lt;br /&gt; &lt;/asp:View&gt; &lt;asp:View runat="server" ID="view_1"&gt; &lt;asp:ScriptManager ID="scrMgr" runat="server"&gt; &lt;/asp:ScriptManager&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt;&lt;asp:Label ID="lblException" CssClass="errorText" runat="server"&gt;&lt;/asp:Label&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;h1 class="blue"&gt; &lt;asp:Label ID="lbl_viewTitle1" runat="server" Text="Label"&gt;&lt;/asp:Label&gt; &lt;/h1&gt; &lt;table border="0"&gt; &lt;tr&gt; &lt;td&gt; &lt;table border="1" style="border-color:Green; border-width:thin;" width="100%"&gt; &lt;tr&gt; &lt;td valign="top"&gt; &lt;table border="0" cellpadding="0" cellspacing="0" width="100%"&gt; &lt;tr id="trUserDetail" runat="server"&gt; &lt;td class="tabRow"&gt; &lt;asp:Label ID="lbl_view1_userID" runat="server" Text="User ID "&gt;&lt;/asp:Label&gt; &lt;/td&gt; &lt;td&gt; &lt;asp:TextBox ID="txt_view1_userID" runat="server" Text="" onblur="CallClientEvent()" AutoPostBack="true" &gt; &lt;/asp:TextBox&gt; &amp;nbsp;&lt;asp:Label ID="Label1" runat="server" ForeColor="Red" Text="*"&gt;&lt;/asp:Label&gt; &amp;nbsp;&lt;div class="smallText" nowrap&gt;&amp;nbsp;&amp;nbsp; (This would be the ID you would normally log on with.)&lt;/div&gt; &lt;/td&gt; &lt;td&gt; &lt;asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="txt_view1_userID" ErrorMessage="* Required field" ValidationGroup="Form2"&gt;&lt;/asp:RequiredFieldValidator&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td width="150" class="tabRow"&gt; &lt;asp:Label ID="lbl_panview3_label2" runat="server" Text="St Nu "&gt;&lt;/asp:Label&gt; &lt;/td&gt; &lt;td width="200"&gt; &lt;asp:TextBox ID="txt_panview3_input2" runat="server" MaxLength="4"&gt;0000&lt;/asp:TextBox&gt; &amp;nbsp;&lt;asp:Label ID="Label8" runat="server" ForeColor="Red" Text="*"&gt;&lt;/asp:Label&gt; &lt;/td&gt; &lt;td&gt; &lt;asp:RangeValidator ID="RangeValidator2" runat="server" ControlToValidate="txt_panview3_input2" ErrorMessage="Please enter a valid 4-digit St Nu " MaximumValue="999999" MinimumValue="1" Type="Integer" ValidationGroup="Form2"&gt;&lt;/asp:RangeValidator&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="3"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ControlToValidate="txt_panview3_input2" ErrorMessage="* Required field" ValidationGroup="Form2"&gt;&lt;/asp:RequiredFieldValidator&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class="tabRow"&gt; &lt;asp:Label ID="lblEmployeeNumber" runat="server" Text="Employee Number "&gt;&lt;/asp:Label&gt; &lt;/td&gt; &lt;td&gt; &lt;asp:TextBox ID="txtEmployeeNumber" runat="server"&gt; &lt;/asp:TextBox&gt; &lt;/td&gt; &lt;td&gt; &lt;asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="txtEmployeeNumber" ErrorMessage="* Required field" ValidationGroup="Form2"&gt;&lt;/asp:RequiredFieldValidator&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td width="150" class="tabRow"&gt; &lt;asp:Label ID="lbl_view1_firstName" runat="server" Text="Firstname "&gt;&lt;/asp:Label&gt; &lt;/td&gt; &lt;td width="200"&gt; &lt;asp:TextBox ID="txt_view1_firstname" runat="server"&gt;&lt;/asp:TextBox&gt; &amp;nbsp;&lt;asp:Label ID="Label9" runat="server" ForeColor="Red" Text="*"&gt;&lt;/asp:Label&gt; &lt;/td&gt; &lt;td&gt; &lt;asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txt_view1_firstname" ErrorMessage="* Required field" ValidationGroup="Form2"&gt;&lt;/asp:RequiredFieldValidator&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class="tabRow"&gt; &lt;asp:Label ID="lbl_view1_surname" runat="server" Text="Surname "&gt;&lt;/asp:Label&gt; &lt;/td&gt; &lt;td&gt; &lt;asp:TextBox ID="txt_view1_surname" runat="server"&gt;&lt;/asp:TextBox&gt; &amp;nbsp;&lt;asp:Label ID="Label10" runat="server" ForeColor="Red" Text="*"&gt;&lt;/asp:Label&gt; &lt;/td&gt; &lt;td&gt; &lt;asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txt_view1_surname" ErrorMessage="* Required field" ValidationGroup="Form2"&gt;&lt;/asp:RequiredFieldValidator&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;asp:Label ID="lblCaption2" runat="server" Text="* Represents fields that needs to be filled mandatory" Font-Size="XX-Small" ForeColor="Red"&gt;&lt;/asp:Label&gt; &lt;hr /&gt; &lt;table border="0" cellpadding="0" cellspacing="0" width="100%"&gt; &lt;tr&gt; &lt;td&gt; &lt;asp:Panel ID="panelHO" runat="server"&gt; &lt;table border="0" cellpadding="0" cellspacing="0" width="100%"&gt; &lt;tr&gt; &lt;td align="left" width="200"&gt; &lt;asp:Label ID="lbl_HO_wu" runat="server" CssClass="boldLabel" Text="Role" /&gt; &lt;/td&gt; &lt;td align="left" width="200"&gt; &lt;asp:Label ID="lbl_panview1_label1" runat="server" CssClass="boldLabel" Text="Dep" /&gt; &lt;/td&gt; &lt;td&gt; &amp;nbsp; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="3"&gt; &amp;nbsp; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td align="left" valign="top"&gt; &lt;asp:CheckBoxList ID="chkBx_HO_wu" runat="server" /&gt; &lt;span id="lbl_chkBx_HO_wu" class="errorText"&gt;&lt;/span&gt; &lt;/td&gt; &lt;td align="left" valign="top"&gt; &lt;asp:DropDownList ID="ddl_panview1_ddinput1" runat="server"&gt; &lt;asp:ListItem&gt;Avebury&lt;/asp:ListItem&gt; &lt;/asp:DropDownList&gt; &lt;/td&gt; &lt;td&gt; &amp;nbsp; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/asp:Panel&gt; &lt;asp:Panel ID="panelRegion" runat="server"&gt; &lt;table border="0" cellpadding="0" cellspacing="0" width="100%"&gt; &lt;tr&gt; &lt;td width="30%"&gt; &lt;asp:Label ID="lbl_Region_wu" runat="server" CssClass="boldLabel" Text="Role" /&gt; &lt;/td&gt; &lt;td width="30%"&gt; &lt;asp:Label ID="lbl_panview2_label1" runat="server" CssClass="boldLabel" Text="Region" /&gt; &lt;/td&gt; &lt;td&gt; &amp;nbsp;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="3"&gt; &amp;nbsp; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td valign="top"&gt; &lt;asp:CheckBoxList ID="chkBx_Region_wu" runat="server" /&gt; &lt;span id="lbl_chkBx_Region_wu" class="errorText"&gt;&lt;/span&gt; &lt;/td&gt; &lt;td valign="top"&gt; &lt;asp:DropDownList ID="ddl_panview2_ddinput1" runat="server"&gt; &lt;asp:ListItem&gt;Northern (NORTHERN)&lt;/asp:ListItem&gt; &lt;asp:ListItem&gt;Central (CENTRAL)&lt;/asp:ListItem&gt; &lt;asp:ListItem&gt;Southern (SOUTHERN)&lt;/asp:ListItem&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload