1.jq设置button的显示与隐藏
$('button[name=\'btnPrint\']').css("display", "inline");
$('button[name=\'btnPrint\']').css("display", "none");
2.根据身份证取生日
function getBirthdayFromSFZ(val){
var birthdayValue;
// 15位身份证号码
if(15==val.length){
birthdayValue = val.charAt(6)+val.charAt(7);
if(parseInt(birthdayValue)<10){
birthdayValue = '20'+birthdayValue;
}else{
birthdayValue = '19'+birthdayValue;
}
birthdayValue=birthdayValue+'-'+val.charAt(8)+val.charAt(9)+'-'+val.charAt(10)+val.charAt(11);
}
// 18位身份证号码
if(18==val.length){
birthdayValue=val.charAt(6)+val.charAt(7)+val.charAt(8)+val.charAt(9)+'-'+val.charAt(10)+val.charAt(11)+'-'+val.charAt(12)+val.charAt(13);
}
return birthdayValue;
}
3.根据身份证取性别
前1、2位数字表示所在省份的代码; 第3、4位数字表示所在城市的代码;
第5、6位数字所在区县的代码;第7~14位数字表示出生年、月、日;
第15、16位数字表示:所在地的派出所的代码;第17位数字表示性别:奇数表示男性,偶数表示女性;
第18位数字是校检码是随计算机的随机产生, 用来检验身份证的正确性
function getSexFromSFZ(val){
var sexValue;
if(15==val.length){// 15位身份证号码
if(parseInt(val.charAt(14)/2)*2!=val.charAt(14)){
sexValue=1;
}else {
sexValue=2;
}
}
if(18==val.length){// 18位身份证号码
if(parseInt(val.charAt(16)/2)*2!=val.charAt(16)) {
sexValue=1;
}else {
sexValue=2;
}
}
return sexValue;
}
4.开头1位大写字母,后面9位数字
function isEnglishAndNumber(v) {
var re = new RegExp("^[A-Z][0-9]{9}$");
if (re.test(v)) return true;
return false;
}
5.miniUI禁用控件
var controls=mini.findControls(function(control){
if(control.type=="textbox"||control.type=="combobox"||control.type=="datepicker") return true;
})
$(controls).each(function(i,item){
item.setEnabled(false);
});
6.计算两个日期间的天数
function dateCompared(date1,date2){//参数日期
var diff = Math.abs(date1.getTime()-date2.getTime());
var result = parseInt(diff/(1000*60*60*24));
return result;
}
7.JS判断值是否为空
function isEmpty(data) {
return data == "" || data == undefined || data == null;
}
8.页面重新加载刷新
window.location.reload();
9.选中所有行
grid.getSelecteds();
10.选中当前行
grid.getSelected();