如何自定义所需弹出窗口的文本?

时间:2014-07-22 11:55:25

标签: jquery html css html5

当提交表单并且没有填写必填字段时,会显示一个自动弹出窗口,显示相对于该字段的位置:

enter image description here

<form id="frm" action="<?php echo PAGE_SERVICE; ?>?action=ServiceAjouterAbonneExec" method="post" name="frm" enctype="">
    <div class="toggle">
        <table>
            <tr>
                <td><b><?php echo _getText("admin.login.form.titre");?></b></td>
                <td><input type="text" name="login" id="login" maxlength="25" required /></td>
            </tr>
            <tr>
                <td><b><?php echo _getText("admin.mdp.form.titre");?></b></td>
                <td><input type="password" name="mdp" id="mdp" maxlength="50" required /></td>
            </tr>
            ...
            <tr>
                <td colspan="2" align="right" ><input name="btnValider" id="btnValider" type="submit" value="<?php echo _getText("main.valider");?>"  class="btn btn-blue"/></td>
            </tr>
        </table>
    </div>

    </form>

当用户输入已存在于数据库中的现有登录时,我想显示类似的弹出窗口。怎么做?

1 个答案:

答案 0 :(得分:1)

您可以使用oninvalid="this.setCustomValidity('Enter Value Here')"

<form id="form">
    <input name="test" required placeholder="Required value" oninvalid="this.setCustomValidity('Enter Value Here')" oninput="setCustomValidity('')" />
    <input type="submit" name="submit" value="submit" />
</form>

http://jsfiddle.net/xmcUk/

相关问题