js日期格式化
方法一:
Date.prototype.Format = function (fmt) { //author: meizz
var o = {
"M+": this.getMonth() + 1, //月份
"d+": this.getDate(), //日
"h+": this.getHours(), //小时
"m+": this.getMinutes(), //分
"s+": this.getSeconds(), //秒
"q+": Math.floor((this.getMonth() + 3) / 3), //季度
"S": this.getMilliseconds() //毫秒
};
if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o)
if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
return fmt;
}
调用:
var time1 = new Date().format("yyyy-MM-dd hh:mm:ss");
var time2 = new Date().Format("yyyy-MM-dd");
//格式化日期
function formatDate() {
var value2 = new Date();
var year = value2.getFullYear();
var month = value2.getMonth() + 1 < 10 ? "0" + (value2.getMonth() + 1) : value2.getMonth() + 1;
var day = value2.getDate() < 10 ? "0" + value2.getDate() : value2.getDate();
var currentDate = year + "-" + month + "-" + day;
return currentDate;
}
2、input禁止键盘及中文输入,但可以点击
禁止键盘及中文输入,但又不能用readonly 而且还需兼容ie 和 ff , 为了完成这功能费了蛮大功夫,呵呵,在此记录以便日后之用;另外禁止粘贴 onpaste="return false"
禁止键盘按键输入及中文输入
ime-mode CSS提议属性
语法:
ime-mode : auto | active | inactive | disabled
参数:
auto : 不影响IME的状态。与不指定ime-mode属性时相同
active : 指定所有使用IME输入的字符。即激活本地语言输入法。用户仍可以撤销激活IME
inactive : 指定所有不使用IME输入的字符。即激活非本地语言。用户仍可以撤销激活IME
disabled : 完全禁用IME。对于有焦点的控件(如输入框),用户不可以激活IME
文本框里面不能手动输入