1

My birthdate field was created by JQuery using datepicker function then the required field validation is handled by AngularJS using ng-show whenver I submit the form there is a error handling but when I choose date in the field the error message is not remove.

<input type="text name="birthdate" id="datepicker" ng-model="birthdate" readonly required >
  <span id="errordate" ng-show="submitted && form.birthdate.$error.required">*required</span><br>

<script>
          $function(){
           $('#datepicker').datepicker();
         });
</script>

Here is the form look at the birthdate field Please Help me thank you.

3
  • Is there any question? Commented Jul 1, 2016 at 3:23
  • my question sir is the error message in birthdate field is not removing when I select a date. Commented Jul 1, 2016 at 3:24
  • Please take a look on my answer. I included an snippet code for ui bootstrap Commented Jul 1, 2016 at 11:24

2 Answers 2

2

JQuery and angular are paradigmatically differents.

If you want a jQuery like query selector. Please use the built in jQuery from angular.

For date picker you should use Ui-bootstrap. It's 100% angular compatible. You won't see those errors.

Take a look in this snippet with ui-bootstrap here.

In case you need to use jQuery. Every moment you chance any attribute that angular are "watching" you have to update the angular's digest with:

$scope.$apply()

Where all $scope attributes will update the values.

However, I strongly suggest you to don't use $apply() never. I suggest you to not use jQuery as well.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you now I understand. :)
0

When jQuery DatePicker apply change to <input>, AngularJS does not know this change, you must call $scope.$apply() to make AngularJS check and apply new changes. But I think you should use $timeout to apply this change and avoid AngularJS inprog error, more information here.

Here is my ONLINE DEMO. Hope this help!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.