具体化最佳实践验证空场 [英] materialize best practice validate empty field

查看:109
本文介绍了具体化最佳实践验证空场的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用此表格

<div class="row">
    <form class="col s12">
        <div class="row">
            <div class="input-field col s12">
                <input id="email2" type="email" class="validate">
                <label for="email2" data-error="wrong" data-success="right">Email</label>
            </div>
            <div class="input-field col s12">
                <input id="example" name="example" type="text" class="validate" required="" aria-required="true">
                <label for="example" data-error="wrong" data-success="right">Field</label>
            </div>
        </div>
    </form>
</div>

邮件字段正常。如果我在不正确的邮件地址中发布错误消息。

mail field is ok. if I post in an incorrect mail address error message appears.

示例字段不起作用。我会检查字段是否为空,然后显示错误。

example field not work. i would check if field is not empty and then show error.

出了什么问题?

推荐答案

您忘记添加 required = aria-required =true $ b这里的$ b是完整的代码段:

You forgot to add required="" and aria-required="true" here is the completes snippet:

<div class="row">
    <form class="col s12">
        <div class="row">
            <div class="input-field col s12">
                <input id="email2" type="email" class="validate" required="" aria-required="true">
                <label for="email2" data-error="wrong" data-success="right">Email</label>
            </div>
            <div class="input-field col s12">
                <input id="example" name="example" type="text" class="validate" required="" aria-required="true">
                <label for="example" data-error="wrong" data-success="right">Field</label>
            </div>
            <div class="input-field col s12">
                <button class="btn waves-effect waves-light" type="submit" name="action">Submit</button>
            </div>
        </div>
    </form>
</div>

http:// jsfiddle.net/u76rdq2h/

这篇关于具体化最佳实践验证空场的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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