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

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

问题描述

 < form class =form-asdrole =form> 
< h2 class =form-signin-heading> login< / h2>< hr />
< label class =control-labelfor =username>用户名< / label>
< input class =form-controltype =emailrequired =placeholder =usernamedata-error =enter valid username>< / input&
< label class =control-labelfor =username> password< / label>
< input class =form-controltype =passwordrequired =placeholder =Password>< / input&
< label class =checkbox>< / label>
< button class =btn btn-lg btn-primarytype =submit> submit< / button>
< / form>

如何更改require字段请填写此字段的弹出式的默认消息

c> code>无效的事件。



喜欢下: -

 < input class =form-controltype =emailrequired =placeholder =usernameoninvalid =this.setCustomValidity('Please Enter valid email') < / input> 


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

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

解决方案

You can use setCustomValidity function when oninvalid event occurs.

Like bellow:-

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

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

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