如何在bootstrap中的form-control的popover中更改必填字段的默认消息? [英] How to change the default message of the required field in the popover of form-control in bootstrap?

查看:28
本文介绍了如何在bootstrap中的form-control的popover中更改必填字段的默认消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

我们如何更改要求字段弹出框的默认消息请填写此字段"为请输入用户名"

how can we change this default message of popover of the require field "Please fill out this field "to "please enter username"

推荐答案

oninvalid 事件发生时,您可以使用 setCustomValidity 函数.

You can use setCustomValidity function when oninvalid event occurs.

如下所示:-

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

更新:-

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

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

这篇关于如何在bootstrap中的form-control的popover中更改必填字段的默认消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆