1、返回历史上一页
onclick="window.history.go(-1)"
2、重置按钮
onclick="javascript:window.history.back();"
3、输入框字数限制
<input type="text" id="name" maxlength="20" placeholder="最大长度为20"/>
$(document).ready(function(){
$("input#name").keyup(function(){
if ($("input#name").val().length >= 20){
parent.$.messager.alert("温馨提示","最多输入20个字符!","info");
}
});
});
说一下其中的几个属性:
maxlength:输入字段的最大长度;
placeholder:描述输入字段预期值的提示信息;
readonly:只读不可修改,设置了该属性的表单会被提交;
disabled:不可修改,设置了该属性的表单不会被提交。
4、只能输入正整数
onkeyup="value=value.replace(/[^\d]/,'')"
onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/,''))"
5、点击输入框变色
id属性为:name
#name:HOVER{border:1px solid red;}