Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <asp:CustomValidator ID="CustomValidator2" runat="server"
- EnableClientScript="true" OnServerValidate="ins_server" ClientValidationFunction ="ins_client"
- ErrorMessage="CustomValidator"> * Insurance dates not valid without supporting attached document</asp:CustomValidator>
- protected void ins_server(object source, ServerValidateEventArgs args)
- {
- //new user
- if (PageMode == PageModes.NewVessel)
- {
- if (fuAttachment.HasFile && datetimepickerinsend != null && datetimepickerinsstart != null)
- {
- args.IsValid = true;
- }
- else
- {
- args.IsValid = false;
- }
- }
- //existing user
- if (PageMode == PageModes.EditVessel)
- {
- args.IsValid = true;
- }
- }
- //declerations
- var insurancestart;
- var insuranceend;
- var filesattached;
- function ins_client(sender, e) {
- if (pagemode == 'EditVessel') {
- e.IsValid = true;
- }
- if (pagemode == 'NewVessel') {
- if (insurancestart !== '' && insuranceend !== '' && filesattached > 0) {
- e.IsValid = true;
- }
- else {
- e.IsValid = false;
- }
- }
- }
- <script type="text/javascript">
- var pagemode;
- $(document).ready(function () {
- // removed var to give global scope
- pagemode = '<%=this.PageMode.ToString()%>';
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement