Saturday, October 18, 2014

how to validate for 3 combo boxes using javascript

how to validate for 3 combo boxes using javascript
-----------------------------------------------------

<script type="text/javascript"> function onChange(obj) { var txtPRNO = document.getElementById("<%=txtPRNO.ClientID %>"); var cbAuth1 = document.getElementById('<%=cbAuthoriser1.ClientId%>'); var cbAuth2 = document.getElementById('<%=cbAuthoriser2.ClientId%>'); var cbAuth3 = document.getElementById('<%=cbAuthoriser3.ClientId%>'); if (obj == 1) { if (cbAuth1.value != "0") { if (cbAuth1.value == cbAuth2.value || cbAuth1.value == cbAuth3.value) { alert("Authoriser already selected. Plese selected another one. "); document.getElementById('<% =btndummy.ClientID %>').click(); cbAuth1.focus(); return false; } return false; } } if (obj == 2) { if (cbAuth2.value != "0") { if (cbAuth2.value == cbAuth1.value || cbAuth2.value == cbAuth3.value) { alert("Authoriser already selected. Plese selected another one. "); document.getElementById('<% =btndummy1.ClientID %>').click(); cbAuth2.focus(); return false; } return false; } } if (obj == 3) { if (cbAuth3.value != "0") { if (cbAuth3.value == cbAuth1.value || cbAuth3.value == cbAuth2.value) { alert("Authoriser already selected. Plese selected another one. "); document.getElementById('<% =btndummy2.ClientID %>').click(); cbAuth3.focus(); return false; } return false; } } return true; } </script>

No comments:

Post a Comment