Anand jain Anand jain - 5 months ago 26
AngularJS Question

How to call a function when bValidator function returns true?

Below is my code, How can I call SubmitMedicalSignup() function once bValidator return true only on submit button click ?

<form method="post" data-bvalidator-validate data-bvalidator-option-validate-till-invalid="true">
<label class="label required"> First Name <font>:</font> </label>
<input type="text" name="contact_person_first_name" ng-model="MedicalData.contact_person_first_name" class="form-control" data-bvalidator="alpha,minlen[50],required" data-bvalidator-msg="First Name Required.">
<button type="submit" name="" id="" ng-click="SubmitMedicalSignup()" value="Register as a physician" class="btn-blue"> Submit
</form>

<!-- validation -->
<script type="text/javascript" src="<?php echo FRONTEND_THEME_URL ?>js/vendor/jquery.bvalidator.js"></script>
<script type="text/javascript" src="<?php echo FRONTEND_THEME_URL ?>js/themes/presenters/default.min.js"></script>
<script type="text/javascript" src="<?php echo FRONTEND_THEME_URL ?>js/themes/gray/gray.js"></script>
<link href="<?php echo FRONTEND_THEME_URL ?>js/themes/gray/gray.css" rel="stylesheet" />
<script type="text/javascript">
$(document).ready(function () {
$('form').bValidator();
});
</script>

Answer

Call Action method on submit like ng-submit="function_name()"

<form method="post" data-bvalidator-validate data-bvalidator-option-validate-till-invalid="true" ng-submit="function_name()">

then it will run first bvalidator function then it will call on submit function.