下面介紹兩種js驗證的方式:
方法一:
js:
html:
<div>
<
asp:textbox
id="textbox1"
runat
="server"
onblur
="check();"
>
asp:textbox
>
<
asp:button
id="button1"
runat
="server"
text
="button"
/>
div>
上面的方法是驗證yyyy-mm-dd日期格式,不能驗證「2012-11-45」之類的不正確的日期
方法二:
js:
html:
<div>
<
asp:textbox
id="textbox1"
runat
="server"
onblur
="check();"
>
asp:textbox
>
<
asp:button
id="button1"
runat
="server"
text
="button"
/>
div>
這個方法驗證的比較全面
補充乙個方法,方法三:
js
functionrqcheck(rq) )(-|\/)(\d)\2(\d)$/);
if (result == null
)
return
false
;
var d = new date(result[1], result[3] - 1, result[4]);
return (d.getfullyear() == result[1] && (d.getmonth() + 1) == result[3] && d.getdate() == result[4]);
}function
checkadd()
return
ret;
}
此方法實現效果和方法二相同
js驗證日期格式
function checkdate 2 9 d 10 12 0?13578 3 01 12 0 9 0?1 9 1 8 9 d 2 9 d 11 0?469 30 12 0 9 0?1 9 1 8 9 d 2 9 d 0?2 2 0 8 1 0 9 0?1 9 2468 048 00 0?2 29...
js驗證日期格式
下面介紹兩種js驗證的方式 方法一 js html div asp textbox id textbox1 runat server onblur check asp textbox asp button id button1 runat server text button div 上面的方法是驗...
js驗證日期格式的函式
下面介紹兩種js驗證的方式 方法一 js html div asp textbox id textbox1 runat server onblur check asp textbox asp button id button1 runat server text button div 上面的方法是驗...