便利的html5 之 required、number 、pattern

html5对于表单验证提供了很多自识别功能,非常的便利。

看代码,

<!--head start-->
<include file="Public:head" />
<!-- style here  -->
<!--head end -->
<section class="panel">
    <div class="panel-body">
        <form role="form" id="myform" method="post" enctype="multipart/form-data">
            <input type="hidden" name="id" value="{$info.id}">
            <div class="form-group">
                <label for="">名称</label>
                <input type="text" name="name" class="form-control" id="name" placeholder="" value="{$info.name}" required>
            </div>

            <div class="form-group">
                <label for="">排序(数字大靠前)</label>
                <input type="number" name="sort" value="{$info.sort}" class="form-control" id="sort" placeholder="" required>
            </div>

            <div class="form-group">
                <label for="">拼音/英文</label>
                <input type="text" name="spell" class="form-control" id="spell" placeholder="" value="{$info.spell}" pattern="^[a-zA-Z]+$" required>
            </div>
            <button type="submit" class="btn btn-info">提交</button>
        </form>
    </div>
</section>
<!--foot start-->
<include file="Public:foot" />
<!--foot end -->
<!-- script here  -->
<script>
var index = parent.layer.getFrameIndex(window.name);
var handle_status = '{$handle_status}';
if ( handle_status == '1' ) {
    parent.$("#handle_status").val('1');
    parent.layer.close(index);
} else if ( handle_status == '2' ) {
    parent.$("#handle_status").val('2');
    parent.layer.close(index);
}

</script>

看效果,
422101-20160505175210138-1749068641.png

422101-20160505175217279-552845080.png

422101-20160505175224685-997095519.png



本文转自TBHacker博客园博客,原文链接:http://www.cnblogs.com/jiqing9006/p/5462751.html,如需转载请自行联系原作者

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值