search

Home  >  Q&A  >  body text

angular.js - angular form formatting tips

<form name="form">
<label for="input">name</label>
<input name="input"></input>
<span id="sp1">name is required</span>
<span id="sp2">max length is 10</span>
</form>
How to control #sp1 to hide when not clicked, the format is correct to hide
sp2 will only be displayed if it exceeds the length

给我你的怀抱给我你的怀抱2814 days ago572

reply all(1)I'll reply

  • 怪我咯

    怪我咯2017-05-15 17:09:56

    <form name="form">
    <label for="input">姓名</label>
    <input name="input" ng-maxlength="10" required></input>
    <span id="sp1" ng-show="!form.input.$pristine">name is required</span>
    <span id="sp2" ng-show="form.input.$invalid">max length is 10</span>
    </form>

    Anguarljs form validation reference document:
    http://www.cnblogs.com/rohelm...

    reply
    0
  • Cancelreply