My goal is to validated field(s) that has a class name or Id using the bootstrap validator
Here is the example code :
HTML:
<input id="myFirstId" class="myClass" type="text" name="myFirstName" />
<input id="mySecondId" class="myClass" type="text" name="myLastName" />
JS:
 $('#myForm').bootstrapValidator({
        fields : {
            myFirstName : {      
                validators : {
                    notEmpty : {
                        message : 'required'
                    }
                }
            },
            myLastName : {
                validators : {
                    notEmpty : {
                        message : 'required'
                    }
                }
            }
        }
 });
but i want a single block to validated those two element using bootstrap validator
ex.
$('#myForm').bootstrapValidator({
        fields : {
            myClass : {      // <-- this is not working but i want to validate those
                             // object with has 'myClass' class.
                validators : {
                    notEmpty : {
                        message : 'required'
                    }
                }
            }
        }
 });
                See http://bootstrapvalidator.com/settings/#field-selector
You can use selector instead of name to use a class name:
$('#myForm').bootstrapValidator({
    fields: {
        myClass: {
            selector: '.myClass',
            validators: {
                notEmpty: {
                    message: 'required'
                }
            }
        },
    }
});
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With