jquery.formtips.js是一款JQuery表单提示信息插件,它可以在文本框中以浅色的字符串提示用户如何输入,以提高表单输入时的可操作性。
参数说明:
tippedClass:'class' //指定tip的样式
选项 | 说明 |
url | 表单提交数据的地址 |
type | form提交的方式(method:post/get) |
target | 服务器返回的响应数据显示在元素(Id)号 |
beforeSerialize: function($form, options) | 表单数据被序列化之前执行的回调函数,如果在内部return false将终止序列化和提交。 |
beforeSubmit: function(arr, $form, options) | 表单数据被序列化成arr数组,并且在提交前触发的回调函数。 |
error | 提交失败执行的回调函数 |
success | 提交成功后执行的回调函数 |
data | 除了表单数据外,还需要额外提交到服务器的数据 |
iframe | 如果有是否应该使用iframe来上传文件(对旧版本浏览器而言) |
iframeSrc | 为元素设定src属性值 |
iframeTarget | 如果你想用自己的iframe来上传文件,可以将Id传给这个属性 |
dataType | 期望服务器返回数据类型 |
clearForm | 提交成功后是否清空表单中的字段值 |
restForm | 提交成功后是否重置表单中的字段值,即恢复到页面加载时的状态 |
timeout | 设置请求时间,超过该时间后,自动退出请求,单位(毫秒) |
forceSync | |
semantic | |
uploadProgress |
<form id="formContact" name="formContact" method="post" action="">
<dl>
<dt>姓名</dt>
<dd>
<input type="text" name="name" id="name" title="请输入您的姓名。" value="" size="20" maxlength="256" />
</dd>
<dt>拼音</dt>
<dd>
<input type="text" name="kana_name" id="kana_name" title="请输入姓名的拼音。" value="" size="20" maxlength="256" />
</dd>
<dt>我要反映问题</dt>
<dd>
<textarea name="message" id="message" title="如果您有任何问题,请在此输入。" cols="20" rows="5"></textarea>
</dd>
</dl>
<input type="submit" name="submitbtm" id="submitbtm" value="提交" />
</form>
[CSS]
<style>
.tipped {color: #bbb;}
</style>
<script>
$(function() {
$('form input.help, form textarea.help').formtips({tippedClass: 'tipped'});
});
</script>
GitHub 地址 :https://github.com/docstun/jquery-formtips