<script type="text/javascript"> function Validate() { var txt1 = document.getElementById('TxtName'); var txt2 = document.getElementById('DDLReason'); var txt3 = document.getElementById('DDLCondition'); var uploadfile = document.getElementById('FileUploadTurnInRequest'); if(txt1.value == '') { alert('Please enter Name'); return false; } if(uploadfile.value == '') { alert('Please upload the attachment'); return false; } if(document.getElementById('<%=DDLReason.ClientID%>').selectedIndex == 0) { alert("Please Select Reason"); return false; } if(document.getElementById('<%=DDLcondition.ClientID%>').selectedIndex == 0) { alert("Please Select Condition"); return false; } else { return confirm('Are you Sure, you want to Submit ?') } } </script>
<asp:ImageButton ID="btnUpdate" runat="server" CausesValidation="true" ImageUrl="~/User/Images/Submit1.png" Width="180px" Height="40px" OnClientClick="javascript:return Validate()" onclick="btnUpdate_Click"/>
function validation(thisform) { with(thisform) { if(validateFileExtension(file, "valid_msg", "pdf files are only allowed!", new Array("pdf")) == false) { return false; } if(validateFileSize(file,1048576, "valid_msg", "Document size should be less than 1MB !")==false) { return false; } } }
var uploadfile = document.getElementById('FileUploadTurnInRequest'); if (uploadfile .value.match(/pdf$/) || uploadfile .value.match(/PDF$/)) { return true; } else{return false;}
<asp:FileUpload ID="flUpld" runat="server" /> <asp:RegularExpressionValidator id="RegularExpressionValidator1" runat="server" ErrorMessage="Only PDF files are allowed!" ValidationExpression="^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))(.pdf|.PDF)$" ControlToValidate="flUpld" CssClass="text-red"></asp:RegularExpressionValidator>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)