<form class="form-asd" role="form"> <h2 class="form-signin-heading">login</h2><hr /> <label class="control-label" for="username">Username</label> <input class="form-control" type="email" required="" placeholder="username"data-error="enter valid username"></input> <label class="control-label" for="username">password</label> <input class="form-control" type="password" required=" " placeholder="Password"></input> <label class="checkbox"></label> <button class="btn btn-lg btn-primary " type="submit">submit</button> </form>
我们该如何更改“要求”字段“请填写此字段”以“请输入用户名”的默认弹出消息
事件发生setCustomValidity时可以使用功能oninvalid。
setCustomValidity
oninvalid
如下所示:
<input class="form-control" type="email" required="" placeholder="username" oninvalid="this.setCustomValidity('Please Enter valid email')"> </input>
开始输入后要清除消息,请使用use oninput="setCustomValidity('')属性清除消息。
oninput="setCustomValidity('')
<input class="form-control" type="email" required="" placeholder="username" oninvalid="this.setCustomValidity('Please Enter valid email')" oninput="setCustomValidity('')"></input>