<script type="text/javascript">
function validation() {
try {
//for textbox
if (document.getElementById("<%= textboxID.ClientID %>").value == "") {
alert('Please Enter Invoice Number');
return false;
}
//for dropdown box
if (document.getElementById("<%= ddlID.ClientID %>").selectedIndex == 0) { alert('Please Select Nature Of Service'); return false; }
//for upload file control
var File = document.getElementById("<%= fuID.ClientID %>");
if (File.value == "") { alert('Please Select File For Upload'); return false; }
var flag = false;
var inputElements = document.getElementsByTagName('input');
for (var i = 0; i < inputElements.length; i++) {
var myElement = inputElements[i];
if (myElement.type === "checkbox") {
if (myElement.checked) {
flag = true;
return true;
}
}
}
if (flag == false) {
alert('Please select option'); return false;
}
}
catch (ex) { alert(ex.get_Message()); }
}
</script>
In Design mode add this code:
<asp:Button ID="btnSubmit" runat="server" CssClass="btn" Text="Submit" OnClick="btnSubmit_Click"
OnClientClick="return validation();" />