1.input 输入实时判断
<input type = "text" id = "set_phone"/>
$(document).on("input change blur", "#set_phone", function () {
//手机 1.必须是11位数字 首字母必须是1
if (/^1[3|4|5|8][0-9]\d{8}$/.test($(this).val())) {}else{
}
});
2.
var point = {"abc":1,"bcd":2,"efg":3};
for (var option in point)
{
var $option = $("#" + option);
if (typeof point[option] === "bool")
{
$option.prop("checked", point[option]);
}
else if (typeof point[option] === "string")
{
if ($option.is("select") == true)
{
$option.children("option[value=" + point[option] + "]").prop("selected", true);
}
else if ($option.is("input[type='text'],[type='password']") == true)
{
$("#" + option).val(point[option]);
}
}
}
3回车响应
$(document).keydown(function (event) {
if (event.keyCode == 13) {
var id = document.activeElement.id;
if (id == "search_input") {
$('#search').triggerHandler('click');
}
else if (id == "page_jump_text") {
$('#page_jump_button').triggerHandler('click');
}
}
});