I am creating an Angular form with a URL field that can be formatted with either the prefix (http: //) or without it. Using Angular to validate the URL by default requires http: //, so I hooked up the following regex, which accepts with and without a prefix:
<input type="text" id="siteAddress" name="siteAddress" ng-model="user.url" ng-pattern="/^(https?:\/\/)?([\dA-Za-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/" required>
This works fine, but when I set type = "url", the Angular check overwrites my custom ng template. This form is intended only for mobile users, therefore type = "url" is important for getting the correct keyboard, therefore their mobile OS does not try to auto-correct their input.
Is it possible to use type = "url" without Angular, using its default check, or is it possible to modify the default Angular check so that it does not accept the url prefix?
Thanks!
source
share