/<([^>]+)>/g //匹配所有的HTML标签
//-------------------------------------------------------------------------------------------
//限制输入框输入
function regInput(obj, reg, inputStr)
{
var docSel = document.selection.createRange()
if (docSel.parentElement().tagName != "INPUT") return false
oSel = docSel.duplicate()
oSel.text = ""
var srcRange = obj.createTextRange()
oSel.setEndPoint("StartToStart", srcRange)
var str = oSel.text + inputStr + srcRange.text.substr(oSel.text.length)
return reg.test(str)
}
//demo:
<INPUT onKeyPress="return regInput(this, /^/d{0,9}$/, String.fromCharCode(event.keyCode))">
//--------------------------------------------
//-------------------------------------------------------------------------------------------
//判断日期格式(精确到秒)
String.prototype.isDateTime = function()
{
var r = this.match(/^(/d{1,4})(-|//)(/d{1,2})/2(/d{1,2}) (/d{1,2}):(/d{1,2}):(/d{1,2})$/);
if(r==null)return false; var d = new Date(r[1], r[3]-1,r[4],r[5],r[6],r[7]);
return (d.getFullYear()==r[1]&&(d.getMonth()+1)==r[3]&&d.getDate()==r[4]&&d.getHours()==r[5]&&d.getMinutes()==r[6]&&d.getSeconds()==r[7]);
}
//判断日期格式(精确到天)
String.prototype.isSmallDateTime = function()
{
var r = this.match(/^(/d{1,4})(-|//)(/d{1,2})/2(/d{1,2})$/);
if(r==null)return false; var d = new Date(r[1], r[3]-1,r[4]);
return (d.getFullYear()==r[1]&&(d.getMonth()+1)==r[3]&&d.getDate()==r[4]);
}
//demo
if((!s_reg_date.value.isSmallDateTime())&&(!s_reg_date.value.isDateTime())){
alert("错误的日期格式!");
//--------------------------------------------------------------------------