本文介绍了如何为下拉框编写客户端验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在下拉框中编写客户端验证我试过这样但不工作
how to write client side validation on drop down boxes i tried like this but not working
function validateInsert(e)
{
var error = true;
var lblStatuVar = $("#lblStatus");
lblStatuVar.css("color", "Red");
var groupname = document.getElementById('<%=txtGroupName.ClientID %>').value;
var dropdown1= document.getElementById('<%=ddldropdown1.ClientID %>').value;
var dropdown2= document.getElementById('<%=ddldropdown2.ClientID %>').value;
if ($("#txtRequestDate")[0].value == "")
{
lblStatuVar.text("Enter request date");
error = false;
}
if (groupname == "") {
lblStatuVar.text("Enter Group Name");
error = false;
}
if (dropdown1 == "--Select--" || dropdown2 == "--Select--")
{
lblStatus.Text = ("Please select atleast two Medical Cov codes");
result = false;
}
推荐答案
var ddlproduct1 = document.getElementById('<%=ddlproducttype1.ClientID%>');
var ddlproductype1 = ddlproduct1.options[ddlproduct1.selectedIndex].value;
if (ddlproductype1 == 0) {
document.getElementById('<%=ddlproducttype1.ClientID %>').className = 'styletxtmandatory';
// alert("Select Product Type.");
return false;
}
试试这个......
Try this ...
这篇关于如何为下拉框编写客户端验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!