Search code examples
jqueryhtmlasp.net-mvcbootstrapvalidator

BootstrapValidator not validating all fields


For some reason BootStrapValidator is not validating all the fields in my div and I am not sure why... Here is the div that I am running into issues with

    <div class="tab-pane" id="AddModerator">
    <div class="panel panel-primary">
        <div class=" panel panel-heading"><strong>Add/Edit Manufacturers</strong></div>
        <div class="panel-body">
            <div class="col-md-6">
                <fieldset class="Myfieldset">
                    <legend class="Mylegend"><h4><b>Address</b></h4></legend>
                    <div class="form-group">
                        <label for="txtAdministrationManufacturerName" class="control-label col-md-2" id="lblAdministrationManufacturerName"><b>Company</b></label>
                        <div class="col-md-10">
                            <input id="txtAdministrationManufacturerName" type="text" class="form-control max-size" name="name" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="txtAdministrationManufacturerAddress1" class="control-label col-md-2" id="lblAdministrationManufacturerAddress1">Address</label>
                        <div class="col-md-10">
                            <input id="txtAdministrationManufacturerAddress1" type="text" class="form-control max-size" name="address" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="AdministrationManufacturertxtAddress2" class="control-label col-md-2" id="lblAdministrationManufacturerAddress2">Address2</label>
                        <div class="col-md-10">
                            <input id="txtAdministrationManufacturerAddress2" type="text" class="form-control max-size" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="txtAdministrationManufacturerCity" class="control-label col-md-2" id="lblAdministrationManufacturerCity">City</label>
                        <div class="col-md-10">
                            <input id="txtAdministrationManufacturerCity" type="text" class="form-control max-size" name="city" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="txtAdministrationManufacturerState" class="control-label col-md-2" id="lblAdministrationManufacturerState">State</label>
                        <div class="col-md-4">
                            <input id="txtAdministrationManufacturerState" type="text" class="form-control" name="state" />
                        </div>
                        <label for="txtAdministrationManufacturerZip" class="control-label col-md-2" id="lblAdministrationManufacturerZip">Zip/Postal</label>
                        <div class="col-md-4">
                            <input id="txtAdministrationManufacturerZip" type="text" class="form-control" name="zip" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="acCountries" class="control-label col-md-2" id="lblAdministrationManufacturerCountry"><b>Country</b></label>
                        <div class="col-md-10">
                            <select id="acCountries" class="form-control" name="country"></select>
                        </div>
                    </div>
                </fieldset>
            </div>
            <div class="col-md-6">
                <fieldset class="Myfieldset">
                    <legend class="Mylegend"><h4><b>Contact</b></h4></legend>
                    <div class="form-group">
                        <label for="txtAdministrationManufacturerContact" class="control-label col-md-2" id="lblAdministrationManufacturerContact">Contact</label>
                        <div class="col-md-10">
                            <input id="txtAdministrationManufacturerContact" type="text" class="form-control max-size" name="manufacturercontact" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="txtAdministrationManufacturerEmail" class="control-label col-md-2" id="lblAdministrationModeratorEmail"><b>Email</b></label>
                        <div class="col-md-10">
                            <input id="txtAdministrationManufacturerEmail" type="text" class="form-control" name="email" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="txtPhone" class="control-label col-md-2" id="lblAdministrationManufacturerPhone">Phone</label>
                        <div class="col-md-10">
                            <input id="txtPhone" type="text" class="form-control max-size" name="phone" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="txtAdministrationManufacturerWorkPhone" class="control-label col-md-2" id="lblAdministrationManufacturerWork">Work</label>
                        <div class="col-md-10">
                            <input id="txtAdministrationManufacturerWorkPhone" type="text" class="form-control max-size" name="work" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="txtAdministrationManufacturerFax" class="control-label col-md-2" id="lblAdministrationManufacturerFax">Fax</label>
                        <div class="col-md-10">
                            <input id="txtAdministrationManufacturerFax" type="text" class="form-control max-size" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="txtAdministrationManufacturerMobile" class="control-label col-md-2" id="lblAdministrationManufacturerMobile">Mobile</label>
                        <div class="col-md-10">
                            <input id="txtAdministrationManufacturerMobile" type="text" class="form-control max-size" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="txtAdministrationManufacturerOther" class="control-label col-md-2" id="lblAdministrationManufacturerOther">Other</label>
                        <div class="col-md-10">
                            <input id="txtAdministrationManufacturerOther" type="text" class="form-control max-size" />
                        </div>
                    </div>
                </fieldset>
            </div>
        </div>
        <div class=" panel panel-heading"><strong>Administration</strong></div>
        <div class="form-group">
            <label for="txtAdministrationManufacturerUserName" class="control-label col-md-2" id="lblAdministrationManufacturerUserName"><b>User Name</b></label>
            <div class="col-md-8">
                <input id="txtAdministrationManufacturerUserName" type="text" class="form-control" name="UserName" />
            </div>
        </div>
        <div class="form-group">
            <label for="ddAdministrationManufacturerCatalog" class="control-label col-md-2" id="lblAdministrationClientCatalogMultiSelect"><b>Catalog</b></label>
            <div class="col-md-8">
                <select id="msManufacturerCatalogs" multiple></select>
            </div>
        </div>
        <div class="form-group">
            <label for="txtAdministrationManufacturerPassword" class="control-label col-md-2" id="lblAdministrationManufacturerPassword"><b>Password</b></label>
            <div class="col-md-8">
                <input id="txtAdministrationManufacturerPassword" type="password" class="form-control" name="manpassword" />
            </div>
            <div class="col-md-2">
                <input id="btnResetManufacturerPassword" type="button" value="Reset" class="btn btn-success" />
            </div>
        </div>
        <div class="form-group">
            <label for="txtAdministrationManufacturerConfirmPassword" class="control-label col-md-2" id="lblAdministrationClientPassword"><b>Confirm Password</b></label>
            <div class="col-md-8">
                <input id="txtAdministrationManufacturerConfirmPassword" type="password" class="form-control" name="manconfirmPassword" />
            </div>
        </div>
        <div class="form-group">
            <label for="txtAdministrationManufacturerAccountNumber" class="control-label col-md-2" id="lblAdministrationClientAccountNumber"><b>Account Number</b></label>
            <div class="col-md-8">
                <input id="txtAdministrationManufacturerAccountNumber" type="text" class="form-control" name="account" />
            </div>
        </div>

        <div class="form-group">
            <div class="col-md-4 col-md-offset-2">
                <input id="btnSaveNewManufacturer" type="button" value="Save" class="btn btn-primary" />
                <input id="btnDeleteNewManufacturer" type="button" value="Delete" class="btn btn-danger" />
                <input id="btnCancelNewManufacturer" type="button" value="Cancel" class="btn btn-primary" />
            </div>
        </div>

        <div class=" panel panel-heading"><strong>Current Active Manufacturers</strong></div>
        <div id="ManufacturerGrid"></div>
    </div>
</div>

and here is my function that does the validation

    function ValidateModeratorTab() {
    var validator = $("#AddModerator").bootstrapValidator({
        feedbackIcons: {
            valid: "glyphicon glyphicon-ok",
            invalid: "glyphicon glyphicon-remove",
            validating: "glyphicon glyphicon-refresh"
        },
        fields: {
            name: {
                message: "Manufacturer name is required",
                validators: {
                    notEmpty: {
                        message: "Please add Manufacturer name"
                    }
                }
            },
            address: {
                message: "Manufacturer name is required",
                validators: {
                    notEmpty: {
                        message: "Please add Manufacturer name"
                    }
                }
            },
            city: {
                message: "Manufacturer name is required",
                validators: {
                    notEmpty: {
                        message: "Please add Manufacturer name"
                    }
                }
            },
            zip: {
                message: "Manufacturer name is required",
                validators: {
                    notEmpty: {
                        message: "Please add Manufacturer name"
                    }
                }
            },
            city: {
                message: "Manufacturer name is required",
                validators: {
                    notEmpty: {
                        message: "Please add Manufacturer name"
                    }
                }
            },
            state: {
                message: "Manufacturer name is required",
                validators: {
                    notEmpty: {
                        message: "Please add Manufacturer name"
                    }
                }
            },
            phone: {
                message: "Manufacturer name is required",
                validators: {
                    notEmpty: {
                        message: "Please add Manufacturer name"
                    }
                }
            },
            email: {
                message: "Email address is required",
                validators: {
                    notEmpty: {
                        message: "Please provide Email address"
                    },
                    emailAddress: {
                        message: "Email address was invalid"
                    }
                }
            },
            manufacturercontact: {
                message: "Contact name is required",
                validators: {
                    notEmpty: {
                        message: "Please add Contact name"
                    }
                }
            },
            catalog: {
                message: "Catalog is required",
                validators: {
                    notEmpty: {
                        message: "Please choose a catalog"
                    }
                }
            },
            country: {
                message: "Country is required",
                validators: {
                    notEmpty: {
                        message: "Please provide a Country"
                    }
                }
            }
        },
        UserName: {
            message: "User Name is required",
            validators: {
                notEmpty: {
                    message: "Please provide a User Name"
                }
            }
        },
        manpassword: {
            validators: {
                notEmpty: {
                    message: "Password is required"
                },
                stringLength: {
                    min: 6,
                    message: "Password must be at least 6 characters long"
                },
                different: {
                    field: "email",
                    message: "Email and Password cannot match"
                }
            }
        },
        manconfirmPassword: {
            validators: {
                notEmpty: {
                    message: "Confirm Password is required"
                },
                identical: {
                    field: "password",
                    message: "Password and Confirmation Password must match"
                }
            }
        },
        account: {
            message: "Account number is required",
            validators: {
                notEmpty: {
                    message: "Please enter an Account number"
                }
            }
        }

    });
}

The fields that are not being validated are..

1)UserName

2)manpassword

3)manconfirmPassword

4)account

Can anyone see what I am doing wrong or where I went wrong?


Solution

  • It looks like you terminated the statement too early (misplaced bracket). Try this:

    function ValidateModeratorTab() {
      var validator = $("#AddModerator").bootstrapValidator({
        feedbackIcons: {
          valid: "glyphicon glyphicon-ok",
          invalid: "glyphicon glyphicon-remove",
          validating: "glyphicon glyphicon-refresh"
        },
        fields: {
          name: {
            message: "Manufacturer name is required",
            validators: {
              notEmpty: {
                message: "Please add Manufacturer name"
              }
            }
          },
          address: {
            message: "Manufacturer name is required",
            validators: {
              notEmpty: {
                message: "Please add Manufacturer name"
              }
            }
          },
          city: {
            message: "Manufacturer name is required",
            validators: {
              notEmpty: {
                message: "Please add Manufacturer name"
              }
            }
          },
          zip: {
            message: "Manufacturer name is required",
            validators: {
              notEmpty: {
                message: "Please add Manufacturer name"
              }
            }
          },
          city: {
            message: "Manufacturer name is required",
            validators: {
              notEmpty: {
                message: "Please add Manufacturer name"
              }
            }
          },
          state: {
            message: "Manufacturer name is required",
            validators: {
              notEmpty: {
                message: "Please add Manufacturer name"
              }
            }
          },
          phone: {
            message: "Manufacturer name is required",
            validators: {
              notEmpty: {
                message: "Please add Manufacturer name"
              }
            }
          },
          email: {
            message: "Email address is required",
            validators: {
              notEmpty: {
                message: "Please provide Email address"
              },
              emailAddress: {
                message: "Email address was invalid"
              }
            }
          },
          manufacturercontact: {
            message: "Contact name is required",
            validators: {
              notEmpty: {
                message: "Please add Contact name"
              }
            }
          },
          catalog: {
            message: "Catalog is required",
            validators: {
              notEmpty: {
                message: "Please choose a catalog"
              }
            }
          },
          country: {
            message: "Country is required",
            validators: {
              notEmpty: {
                message: "Please provide a Country"
              }
            }
          },
          UserName: {
            message: "User Name is required",
            validators: {
              notEmpty: {
                message: "Please provide a User Name"
              }
            }
          },
          manpassword: {
            validators: {
              notEmpty: {
                message: "Password is required"
              },
              stringLength: {
                min: 6,
                message: "Password must be at least 6 characters long"
              },
              different: {
                field: "email",
                message: "Email and Password cannot match"
              }
            }
          },
          manconfirmPassword: {
            validators: {
              notEmpty: {
                message: "Confirm Password is required"
              },
              identical: {
                field: "password",
                message: "Password and Confirmation Password must match"
              }
            }
          },
          account: {
            message: "Account number is required",
            validators: {
              notEmpty: {
                message: "Please enter an Account number"
              }
            }
          }
        }
      });
    }