I tried this but it doesn't work : Demo Link
<form name="myform1">
valid? {{ myform1.$valid }}
<input type="text" name="username1" ng-model="username1" ng-pattern="/^\S.*?\S$/" required/> ng-pattern="/[a-zA-Z0-9^ ]/"<br />
</form>
You can use
^\S*\S+\S*$
It will detect whitespace between string. You can remove starting and ending whitespace by
$scope.username1.trim();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.