小编典典

如何在引导程序的表单控件的弹出窗口中更改必填字段的默认消息?

css

 <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>

我们该如何更改“要求”字段“请填写此字段”以“请输入用户名”的默认弹出消息


阅读 333

收藏
2020-05-16

共1个答案

小编典典

事件发生setCustomValidity时可以使用功能oninvalid

如下所示:

<input class="form-control" type="email" required="" 
    placeholder="username" oninvalid="this.setCustomValidity('Please Enter valid email')">
</input>

更新:-

开始输入后要清除消息,请使用use oninput="setCustomValidity('')属性清除消息。

<input class="form-control" type="email"  required="" placeholder="username"
 oninvalid="this.setCustomValidity('Please Enter valid email')"
 oninput="setCustomValidity('')"></input>
2020-05-16