<div id="divMsg" runat="server" class="alert alert-error fade in" style="display: none;">
<a class="close" data-dismiss="alert" href="#">×</a>
<asp:Label ID="lblMsg" runat="server"></asp:Label>
</div>
<asp:Button ID="BtnSubmit" runat="server" Text="Submit" OnClick="BtnSubmit_Click"
ValidationGroup="R" TabIndex="5" OnClientClick="return ValidateData();" />
function ValidateData() {
var lblMsg = document.getElementById("<%=lblMsg.ClientID%>");
lblMsg.innerHTML = " ";
var divMsg = document.getElementById("<%=divMsg.ClientID%>");
divMsg.style.display = "none";
var txtPrice = document.getElementById("<%=txtPrice.ClientID%>");
var PriceValue = document.getElementById("<%=txtPrice.ClientID%>").value.trim();
if (PriceValue == "") {
lblMsg.innerHTML = "Enter Price!";
divMsg.style.display = "block";
txtPrice.focus();
txtPrice.style.border = "1px solid red";
return false;
}
else {
lblMsg.innerHTML = "";
divMsg.style.display = "none";
txtPrice.focus();
txtPrice.style.border = "1px solid #ddd";
}
var drpCity = document.getElementById("<%=drpCity.ClientID%>");
var CityValue = drpCity.options[drpCity.selectedIndex].value;
if (CityValue == "0") {
lblMsg.innerHTML = "Please Select City!";
divMsg.style.display = "block";
drpCity.focus();
drpCity.style.border = "1px solid red";
return false;
}
else {
lblMsg.innerHTML = "";
divMsg.style.display = "none";
drpCity.focus();
drpCity.style.border = "1px solid #ddd";
}
return true;
}
<a class="close" data-dismiss="alert" href="#">×</a>
<asp:Label ID="lblMsg" runat="server"></asp:Label>
</div>
<asp:Button ID="BtnSubmit" runat="server" Text="Submit" OnClick="BtnSubmit_Click"
ValidationGroup="R" TabIndex="5" OnClientClick="return ValidateData();" />
function ValidateData() {
var lblMsg = document.getElementById("<%=lblMsg.ClientID%>");
lblMsg.innerHTML = " ";
var divMsg = document.getElementById("<%=divMsg.ClientID%>");
divMsg.style.display = "none";
var txtPrice = document.getElementById("<%=txtPrice.ClientID%>");
var PriceValue = document.getElementById("<%=txtPrice.ClientID%>").value.trim();
if (PriceValue == "") {
lblMsg.innerHTML = "Enter Price!";
divMsg.style.display = "block";
txtPrice.focus();
txtPrice.style.border = "1px solid red";
return false;
}
else {
lblMsg.innerHTML = "";
divMsg.style.display = "none";
txtPrice.focus();
txtPrice.style.border = "1px solid #ddd";
}
var drpCity = document.getElementById("<%=drpCity.ClientID%>");
var CityValue = drpCity.options[drpCity.selectedIndex].value;
if (CityValue == "0") {
lblMsg.innerHTML = "Please Select City!";
divMsg.style.display = "block";
drpCity.focus();
drpCity.style.border = "1px solid red";
return false;
}
else {
lblMsg.innerHTML = "";
divMsg.style.display = "none";
drpCity.focus();
drpCity.style.border = "1px solid #ddd";
}
return true;
}
No comments:
Post a Comment