我想验证IP地址。
我的html页面代码如下所示
<md-content class="md-padding" ng-controller="AddNewHostController as vm">
<form name="hostForm" ng-submit="vm.AddNewHost(hostForm.$valid)" novalidate>
<md-content md-theme="dark" class="md-padding" layout="row" layout-sm="column">
<md-input-container>
<input ng-model="vm.host.hostname" required placeholder="Hostame">
</md-input-container>
<md-input-container>
<input ng-model="vm.host.ipaddress" required placeholder="IP Address" ng-pattern="/\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/">
</md-input-container>
<div ng-show="hostForm.$submitted || vm.host.ipaddress.$touched">
<span ng-show="vm.host.ipaddress.$error.pattern">Invalid input</span>
</div>
<md-input-container>
<input ng-model="vm.host.alias" required placeholder="Alias">
</md-input-container>
</md-content>
<md-content class="md-padding">
<button class="md-button md-ink-ripple" style="background-color:#7ec9c2; height: 12px; margin-left: 0px;">Add New Host</button>
</md-content>
</form>
</md-content>
但我的ng-pattern
无效。点击按钮后,我没有收到无效输入错误消息。