This is Simple form.
This is JS code:
$(document).ready(function() {
$('#ledgerHolderjHolderFormEdit').bootstrapValidator({
feedbackIcons: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
JH_INIT: {
validators: {
notEmpty: {
message: "'First Name' is required."
},
regexp: {
regexp: /^07[a-zA-Z0-9.,:;!-@#\$%\^\&*\)\(+=_-`~><|].+$/,
message: "'Mobile Number' must only start with '07'."
},
stringLength: {
min: 5,
max: 30,
message: "'First Name' must be more than 2 and less than 255 characters long."
}
}
}
}
});
});
There are no errors show in console, and could not find errors. Can anyone help me?
In this demo, the Bootstrap form validation is done by using the default behavior. Only the required attribute is added for the fields. Go to the demo page and press the submit button and see how validation message appears:
The div with a class .valid-feedback is the form validation message success. The div with a class . invalid-feedback is the form validation message error. Each class stated above needs to be used together below the input field and then bootstrap with the help of JavaScript will determine which one to show based on user entry upon form submission.
You can actually put the .was-validated class to the form tag even without the help of JavaScript but that will automatically show the form validation states and messages even before the user submits the form.
Bootstrap scopes the :invalid and :valid styles to parent.was-validated class, usually applied to the <form>. Otherwise, any required field without a value shows up as invalid on page load. This way, you may choose when to activate them (typically after form submission is attempted).
Solution Found
There are no effect in form and js. Issue was, I wrote html form in 'edit function'(append html form using jQuery). And after validation function wrote in another function. That is the reason.
After many efforts, I wrote validation inside that 'edit function'. The issue was solved.
Make sure you've included JQuery correctly
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