jrief / django-angular

Let AngularJS play well with Django
http://django-angular.awesto.com/
MIT License
1.23k stars 294 forks source link

Use $touched instead of $dirty and $untouched instead of $pristine #248

Closed jrief closed 7 years ago

jrief commented 8 years ago

This is just a proposal, and I'd like to ask the django-angular community about their opinion.

In form validation, shall we use $touched instead of $dirty?

Currently the behavior like this: Whenever one starts to type into a field, for instance an email address field, which yet does not validate, then after the first character, an error message appears. If we would replace $dirty by $touched this error message would only appear, whenever the field is blurred and the address still invalid.

However, for upstream error messages we still must use $pristine instead of $untouched, so that those messages disappear whenever one starts to type.

What's your opinion about this?

adrienbrunet commented 8 years ago

Well, I agree emailField or UrlField can be quite boring stating it's invalid until we're done typping it. I think it could be a good small improvement. :+1:

adrienbrunet commented 7 years ago

Now that all our community has answered (haha), do you still consider doing it? A workaround could also be to add the following to the fields when needed (from angular doc): ng-model-options="{ updateOn: 'default blur', debounce: { default: 500, blur: 0 } }"

jrief commented 7 years ago

ups, I already use ng-model-options for my production sites.

But anyway, adding support for $touched and $untouched would be a good idea. Hopefully, one of my customers insists on this, to have an incentive for doing it.