1

I use the inbuilt AngularJs directive required, once it validates to false I get a small popup close to the field with the text "Please fill out this field". My problem is that I need the text in a different language, how should I proceed?

I have found some pretty good answers, but none that would solve this for the entire webapp. From my Angular experience I think that a custom directive which uses "setCustomValidity" should do the trick..

1 Answer 1

3

I figured out how to do it (note I use coffeescript):

angular.module('myApp').directive('customRequiredText', () ->
  {
     restrict: 'AE'
     link: (scope, elem, attrs, ctrl) ->
       elem[0].oninvalid = (e) -> e.target.setCustomValidity('Fyll i det här fältet')
       elem[0].oninput = (e) -> e.target.setCustomValidity('')
 }
)
Sign up to request clarification or add additional context in comments.

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.