Prevent Angular from mangling email inputs

后端 未结 2 1115
無奈伤痛
無奈伤痛 2020-12-22 04:11

If I have an , and the user enters an Internationalized Domain Name, Angular (EDIT: except it\'s not Angular\'s fault - see my a

相关标签:
2条回答
  • 2020-12-22 04:28

    As soon as you use ng-model on input type email, angularjs will use its magic on the input.

    Try it without ng-model

    0 讨论(0)
  • 2020-12-22 04:37

    It turns out it's not Angular that's doing it, it's Chrome (Safari does not have the same behaviour, haven't tested other browsers). See for example Input type email value in Chrome with accented characters wrong

    Here's an example of it happening without Angular - try this in Chrome:

    function update() {
      document.getElementById('output').innerText = document.getElementById('inp').value
    }
    <p>Copy this text into the input:</p>
    <p>abc@ábc.com</p>
    <div ng-controller="thing">
      <input id="inp" type="email" onchange="update()">
      <p>Browser says: <span id="output"></span></p>
    </div>

    So the short answer is no, there's no way of stopping this via Angular - and currently there doesn't appear to be a way to tell Chrome not to do it either.

    0 讨论(0)
提交回复
热议问题