Subversion Repositories SmartDukaan

Rev

Rev 21998 | Blame | Compare with Previous | Last modification | View Log | RSS feed

function associateValidator(){
    $('#form').bootstrapValidator({
        fields: {
          registeredBusinessName: {
                validators: {
                    
                        notEmpty: {
                        message: 'Please fill the BusinessName'
                    }
                }
            },

    
            registeredAddress1: {
                validators: {
                   
                    notEmpty: {
                        message: 'Please fill the Address field.'
                    }
                }
            },
            city: {
                validators: {
                  
                    notEmpty: {
                        message: 'Please fill the city '
                    }
                }
            },

             pincode: {
                validators: {
                    notEmpty: {
                        message: 'Please fill your pincode'
                    },
                   
                }
            },

           state: {
                validators: {
                    notEmpty: {
                        message: 'Please select your state'
                    }
                }
            },
       
       district:{
        validators: {
                    notEmpty: {
                        message: 'Please select your district.'
                    }
                }
            },

       

                mobile: {
                validators: {
                    stringLength: {
                       max: 10,
                    },
                    notEmpty: {
                        message: 'Please fill your Mobile'
                    },
             
                    }
                },

                stdcode: {
                validators: {
                   
                    notEmpty: {
                        message: 'Pleasefill your phone number'
                    },
                   
                    }
                },


                telephone: {
                validators: {
                   
                    notEmpty: {
                        message: 'Pleasefill your phone number'
                    },
                   
                    }
                },
                registeredEmail1: {
                validators: {
                    notEmpty: {
                        message: 'Please fill your email address'
                    },
                    emailAddress: {
                        message: 'Please fill a valid email address'
                    }
                }
            },

            registeredEmail2:{
               validators: {
                  
                    emailAddress: {
                        message: 'Please fill valid email address'
                    }
                }
            },

            dinNumber:{
              validators:{
                 notEmpty: {
                        message: 'Please fill the DINumber'
                    }
                }
            },
          

                bEntityDoc:{
                           excluded: false,   
                   validators: {
                            
        notEmpty: {
                        message: 'Document is required.'
                  }
        }
      },
    
    
      angleDoc1:{
           excluded: false,   
                   validators: {
                      
        notEmpty: {
                        message: 'Document is required.'
                  }
        }
      },
    
      angleDoc2:{
           excluded: false,   
                   validators: {
                          
        notEmpty: {
                        message: 'Document is required.'
                  }
        }
      },
      angleDoc3:{
           excluded: false,   
                     validators: {
                          
          notEmpty: {
                    message: 'Document is required.'
              }
            }
          },
        angleDoc4:{
                   excluded: false,   
               validators: {
                   
          notEmpty: {
                          message: 'Document is required.'
                    }
          }
        },
                  
      angleDoc5:{
           excluded: false,   
        validators: {
                              
                      notEmpty: {
                    message: 'Document is required.'
              }
               }
              },

            pan:{
              validators:{

                      stringLength: {
                       max: 10,
                    },
                notEmpty:{
                  message:'Please fill the valid pan Number'
                }

              }
            },

            panDoc:{
                   excluded: false,   
               validators: {
                         
    notEmpty: {
                    message: 'Pan card Document is required.'
              }
    }
  },
  proprietorBusineesName:{
                 validators:{

                notEmpty:{
                  message:'Please fill the field'
                }

              }
            },
            proprietorAddress:{
             validators:{
                notEmpty:{
                  message:'Please fill the field'
                }

              }
            }, 

            proprietorPhone:{
                validators:{

                 stringLength: {
                       max: 10,
                    },
                   notEmpty:{
                  message:'Please fill the field'
                }

              } 
          },   
          proprietorPan:{
              validators:{

             stringLength: {
                       max: 10,
                    },
                  notEmpty:{
                  message:'Please fill the field'
                }

              } 
        },
        proprietorAdhaar:{
             validators:{

            notEmpty:{
                  message:'Please fill the field'
                }

              }  
          },

          proprietorEmail:{
             validators: {
                    notEmpty: {
                        message: 'Please fill the field'
                    },
                    emailAddress: {
                        message: 'Please fill a valid email address'
                    }
                }
            },

            proprietorOwner:{
           validators:{
              stringLength: {
                       max: 10,
                    },
            notEmpty:{
                  message:'Please fill the field'
                }

              } 
            },

            partnerName1:{
                 validators:{

                notEmpty:{
                  message:'Please fill the field'
                }

              }
            },
            partnerAddress1:{
            validators:{
                notEmpty:{
                  message:'Please fill the field'
                }

              }
            }, 

            partnerPhone1:{
                 validators:{
                 stringLength: {
                       max: 10,
                    },
                   notEmpty:{
                  message:'Please fill the field'
                }

              } 
          },   
          partnerPan1:{
            validators:{
             stringLength: {
                       max: 10,
                    },
                  notEmpty:{
                  message:'Please fill the field'
                }

              } 
        },
        partnerAdhaar1:{
             validators:{

            notEmpty:{
                  message:'Please fill the field'
                }

              }  
          },

          partnerEmail1:{
             validators: {
                    notEmpty: {
                        message: 'Please fill the field'
                    },
                    emailAddress: {
                        message: 'Please fill a valid email address'
                    }
                }
            },

            partnerOwner1:{
           validators:{
              stringLength: {
                       max: 10,
                    },
            notEmpty:{
                  message:'Please fill the field'
                }

              } 
            },
        


            shareholderName1:{
                 validators:{

                notEmpty:{
                  message:'Please fill the field'
                }

              }
            },
            shareholderAddress1:{
            validators:{
                notEmpty:{
                  message:'Please fill the field'
                }

              }
            }, 

            shareholderPhone1:{
                 validators:{
                 stringLength: {
                       max: 10,
                    },
                   notEmpty:{
                  message:'Please fill the field'
                }

              } 
          },   
     shareholderPan1:{
             validators:{
             stringLength: {
                       max: 10,
                    },
                  notEmpty:{
                  message:'Please fill the field'
                }

              } 
        },
        shareholderAdhaar1:{
             validators:{

            notEmpty:{
                  message:'Please fill the field'
                }

              }  
          },

          shareholderEmail1:{
             validators: {
                    notEmpty: {
                        message: 'Please fill the field'
                    },
                    emailAddress: {
                        message: 'Please fill a valid email address'
                    }
                }
            },

            shareholderOwner1:{
           validators:{
              stringLength: {
                       max: 10,
                    },
            notEmpty:{
                  message:'Please fill the field'
                }

              } 
            },
            managerName: {
                validators: {
                    
                        notEmpty: {
                        message: 'Please fill the ManagerName'
                    }
                }
            },
            
            managerNo:{
                 validators:{
                 stringLength: {
                       max: 10,
                    },
                   notEmpty:{
                  message:'Please fill the ManagerNo'
                }

              } 
          },

          managerEmail:{
            validators: {
                    notEmpty: {
                        message: 'Please fill the Manageremail'
                    },
                    emailAddress: {
                        message: 'Please fill a valid email address'
                    }
                }
            },
            noOfEmployees:{
                validators:{
                   notEmpty:{
                  message:'Please fill the Number of employees'
                }
            }},
            managementStaff:{
               validators:{
                   notEmpty:{
                  message:'Please fill the  Number of Managementstaff'
                }
            }
        },

        itrDoc:{
                   excluded: false,   
               validators: {
                      
        notEmpty: {
                        message: 'ITR Document is required.'
                  }
        }
      },

        ownershipDoc:{
                
                   excluded: false,   
           validators: {
                   
          notEmpty: {
                          message: 'Ownership Document is required.'
                    }
          }
      },
      
      insuranceDoc:{
           excluded: false,   
          validators: {
              
          notEmpty: {
                          message: 'Insurance Document is required.'
                    }
          }
      },
      loanDoc:{
           excluded: false,   
   
           validators: {
               
           notEmpty: {
                          message: 'Document is required.'
            }
           }
      },
      sanctionDoc:{
           excluded: false,   
      
           validators: {
             
          notEmpty: {
                          message: 'Document is required.'
                    }
          }
      },
      
      chequeCopy:{
           excluded: false,   
      
           validators: {
                 
          notEmpty: {
                          message: 'Document is required.'
                    }
          }
      },

        portalName1:{
             validators:{
                   notEmpty:{
                  message:'Please fill the PortalName'
                }
            }
        },
       east:{
         validators:{
                   notEmpty:{
                  message:'Please fill the Area'
                }
            }
        },
        west:{
         validators:{
                   notEmpty:{
                  message:'Please fill the Area'
                }
            }
        },
        north:{
         validators:{
                   notEmpty:{
                  message:'Please fill the Area'
                }
            }
        },

     south:{
         validators:{
                   notEmpty:{
                  message:'Please fill the Area'
                }
            }
        },

        front:{
         validators:{
                   notEmpty:{
                  message:'Please fill the Area'
                }
            }
        },

        roadSize:{
         validators:{
                   notEmpty:{
                  message:'Please fill the Area'
                }
            }
        },
        storeName:{
            validators:{
                   notEmpty:{
                  message:'Please fill the storename'
                }
            }
        },

        storeAddress:{
            validators:{
                   notEmpty:{
                  message:'Please fill the storeAddress'
                }
            }
        }, 

        accountNumber:{
            validators:{
                   notEmpty:{
                  message:'Please fill the accountnumber'
                }
            }
        },  
        bankName:{
            validators:{
                   notEmpty:{
                  message:'Please fill the bankname'
                }
            }
        },  
        ifscCode:{
            validators:{
                   notEmpty:{
                  message:'Please fill the IFSCcode'
                }
            }
        }, 
        branchName:{
            validators:{
                   notEmpty:{
                  message:'Please fill the Branchname'
                }
            }
        },

        utr:{
           validators:{
                   notEmpty:{
                  message:'Please fill the field'
                }
            }
        } 
        
            }
        }).on('success.form.bv', function(e) {
                $('#form').data('bootstrapValidator').resetForm();

            // Prevent form submission
            e.preventDefault();

            // Get the form instance
            var $form = $(e.target);

            // Get the BootstrapValidator instance
            var bv = $form.data('bootstrapValidator');

            // Use Ajax to submit form data
 var isChecked = jQuery("input[name=bEntity]:checked").val();
      if(!isChecked){
         alert('Please select the type of BusinessEntity');
         return false;
     }else{
         
}
     var isChecked = jQuery("input[name=bPmpDetail]:checked").val();
      if(!isChecked){
         alert('Please select the detail of BusinessEntity');
          return false;
     }else{
         
     }

       var isChecked = jQuery("input[name=businessModel]:checked").val();
      if(!isChecked){
         alert('Please select the BusinessModel');
          return false;
     }else{
         }

        var isChecked = jQuery("input[name=sellingOnline]:checked").val();
      if(!isChecked){
          alert('Please select the Sellingonline');
           return false;
     }else{
         }

    var isChecked = jQuery("input[name=shopArea]:checked").val();
      if(!isChecked){
          alert('Please select the shopArea');
           return false;
     }else{
         }

   var isChecked = jQuery("input[name=shopStatus]:checked").val();
      if(!isChecked){
          alert('Please select the shopstatus');
           return false;
     }else{
         }
         

            var isChecked = jQuery("input[name=shopAvailbility]:checked").val();
      if(!isChecked){
          alert('Please select the shopAvailbility');
           return false;
     }else{
         }

              var isChecked = jQuery("input[name=location]:checked").val();
      if(!isChecked){
          alert('Please select the Loacation of Shop');
           return false;
     }else{
         }


         var isChecked = jQuery("input[name=nearestStore]:checked").val();
      if(!isChecked){
          alert('Please select the NearestStore');
           return false;
     }else{
         }

      var isChecked = jQuery("input[name=ownership]:checked").val();
if(!isChecked){
  alert('Please select the ownership of Shop');
   return false;
}else{
 }

            var isChecked = jQuery("input[name=insurance]:checked").val();
      if(!isChecked){
          alert('Please select the Insurance field');
           return false;
     }else{
         }

     var isChecked = jQuery("input[name=loan]:checked").val();
      if(!isChecked){
          alert('Please select the loan field');
           return false;
     }else{
         }
 var isChecked = jQuery("input[type=checkbox]:checked").val();
      if(!isChecked){
          alert('Please select the Status of shop');
           return false;
     }
      submitFormAsJson($(this));
      });
    }



function submitFormAsJson(jQueryForm){
    jQuery.blockUI({ message: "<h5>Please wait while we upload data to our server</h5>" });
    
    jQuery.ajax({
        url: contexPath +"/register",
        type: 'POST',
        data: JSON.stringify(objectifyForm($("form").serializeArray())),
        success: function (data) {
            //$('#form')[0].reset();
                jQuery.unblockUI();
                jQuery("html").html(data);
        },
     error : function() {
       jQuery.unblockUI();
           alert("OOPS!!!Failed to do changes.Try Again.");
     },
        cache: false,
        contentType: false,
        processData: false
    });
}
//serialize data function
function objectifyForm(formArray) {

          var returnArray = {};
          for (var i = 0; i < formArray.length; i++){
            returnArray[formArray[i]['name']] = formArray[i]['value'];
          }
          return returnArray;
}