$(document).ready(function () { $(".water").each(function () { $tb = $(this); if ($tb.val() != this.title) { $tb.removeClass("water"); } }); $(".water").focus(function () { $tb = $(this); if ($tb.val() == this.title) { $tb.val(""); $tb.removeClass("water"); } }); $(".water").blur(function () { $tb = $(this); if ($.trim($tb.val()) == "") { $tb.val(this.title); $tb.addClass("water"); } }); }); function CustomValidate() { $("#ctl01").validate(); $('[id$=txtTotalDepositAmount]').rules("add", { required: true, number: true, messages: { required: " * Amount is required", number: " * Enter numbers only" } }); $('[id$=ddlJamatkhana]').rules("add", { required: true, messages: { required: " * Please select JK from dropdown" } }); // alert("Valid: " + $("#ctl01").valid()); if ($("#ctl01").valid() == false) return false; if ($("#ctl01").valid() == true) { // Check file extension var filePath = $('[id$=FileUpload1]').val(); if (filePath.length == 0) { alert('You have not specified a file!'); return false; } if (filePath.indexOf('.') == -1) { alert('Invalid filename!'); return false; } var validExtensions = new Array(); var ext = filePath.substring(filePath.lastIndexOf('.') + 1).toLowerCase(); //Add valid extentions in this array validExtensions[0] = 'xls'; validExtensions[1] = 'xlsx'; //validExtensions[1] = 'pdf'; for (var i = 0; i < validExtensions.length; i++) { if (ext == validExtensions[i]) return true; } alert('The file extension ' + ext.toUpperCase() + ' is not allowed! (only XLS or XLSX)'); return false; } }