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>

看效果,

便利的html5 之 required、number 、pattern的更多相关文章

  1. 如何移除HTML5的type=""number""的input标签的上下箭头

    初次使用input的数字输入类型type="number"时会发现默认有个上下的箭头,如下图: 很明显这里不需要这个默认箭头,那么我们如何移出这个默认样式呢? 第一种方式,写css ...

  2. HTML5 <input> required

    要求在提交数据之前必须填写该字段,否则会提交不了   <form>          <input type="text" id="msg" ...

  3. html5中 input的pattern属性 和 details/summary元素

    html5--3.21 课程小结与其他新增元素 一.总结 一句话总结: input的pattern属性可以设置正则验证,比如检测学号的位数和数字区间 details/summary元素配合起来可以做元 ...

  4. 使用html5中required属性

    直接上代码 <form action="${pageContext.request.contextPath}/login/main.do" method="post ...

  5. 解决 html5 input type='number' 类型可以输入e

    当给 input 设置类型为 number 时,比如,我想限制,只能输入 0-9 的正整数,正则表达式如下: /^[-]?$/ // 匹配 0-9 的整数且只匹配 0 次或 1 次 用正则测试,小数点 ...

  6. 一些有用的HTML5 pattern属性

    最近在做手机页面时,遇到数字输入的键盘的问题,之前的做法只是一刀切的使用 type="tel",不过一直觉得九宫格的电话号码键盘上的英文字母太碍事了.于是想要尝试其它的实现方案,最 ...

  7. [HTML5] Input accepts only 6 number characters

    Use 'pattern' tag in html5: <input type="text" pattern="[0-9]{6}" maxlength=& ...

  8. 常用的HTML5 pattern属性

    type="tel" 和 type="number" 的区别 这里还是先那么先交代一下最初遇到的问题.其实无论是tel还是number都不是完美的: type= ...

  9. html5 input number类型使用整理

      一.  html5 input中的数字number类型, 只能输入整数,如果要输入浮点数呢,可以通过max.min和step去定义. type="number" 数字类型 mi ...

随机推荐

  1. 广告系统中weak-and算法原理及编码验证

    wand(weak and)算法基本思路 一般搜索的query比较短,但如果query比较长,如是一段文本,需要搜索相似的文本,这时候一般就需要wand算法,该算法在广告系统中有比较成熟的应 该,主要 ...

  2. Java实战之01Struts2-01简介及环境搭建

    一.Struts2简介 1.Struts2概述 Struts2是Apache发行的MVC开源框架.注意:它只是表现层(MVC)框架. 2.Struts2的来历 Struts1:也是apache开发的一 ...

  3. Peter Pan By: J. M. Barrie

    Audio book: (mp3+txt) http://www.booksshouldbefree.com/book/peter-pan-by-j-m-barrie

  4. 【C++】类型转换

    引言 C++风格的四种类型转换方法:static_cast.dynamic_cast.reinterpret_cast.const_cast. 欢迎来到 lovickie 的博客 http://www ...

  5. SQL Server中count(*), count(col), count(1)的对比

    让我们先看一下BOL里面对count(*)以及count(col)的说明: COUNT(*) 返回组中的项数.包括 NULL 值和重复项. COUNT(ALL expression) 对组中的每一行都 ...

  6. xp 下卸载 硬盘安装的 ubuntu (本人的悲伤史)

    正常启动XP系统,到http://www.sysint.no 下载 MBRFIX.zip,解压,把文件放在C盘, 点击“开始”==“运行”==“cmd”,出现下面图 输入cd\,如下图, 再按回车键, ...

  7. web系列教程之php 与mysql 动态网站 。检索 与更新。

    接着上次WEb 系列开发之php 与mysql动态网站入门. 个人觉得,学习技术就像一棵大树,主干很重要,枝叶其次.对于学习技术,我们应该分清主次关系.怎么学?为什么要学?有一个较好的分寸. 有时候觉 ...

  8. Pyhon编码事项

    1. 永远不要使用import * Pylint代码审查:Wildcard import XXX 如果函数名重名,或者要导入的内容里面包含了from datetime import datetime, ...

  9. C的快速趋向实验 -->

    今天刚学到C的一个新玩法,非常有意思,叫趋向于,写作“-->”,比如说如果要实现一个倒数的程序,我们可以定义一个变量 counter,然后让它趋向于0... #include <stdio ...

  10. 大话设计模式(带目录完整版).pdf等

    点击进入百度网盘 大话设计模式(带目录完整版).pdf等 保存至网盘下载二维码举报 赞(0)| 评论 | 分享至 分享时间:2014-04-01 11:02 | 467次浏览 130次下载 81次保存 ...