javascript验证1
function $id(s) {
return document.getElementById(s);
}
//判断小数
function IsFloat(s) {
if (!/^[+\-]?\d+(.\d+)?$/.test(s))
return false;
else
return true;
}
//判断正小数
function IsPlusFloat(s) {
if (!/^[+]?\d+(.\d+)?$/.test(s))
return false;
else
return true;
}
//判断正整数
function IsPlusInt(s) {
if (!/^\d*$/.test(s))
return false;
else
return true;
}
//判断是否为字母和数字
function CheckName(s) {
if (!/^[A-Za-z0-9._-]+$/.test(s))
return false;
else
return true;
}
//检测Email格式
function IsEmail(s) {
var pattern = /^([a-zA-Z0-9._-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/;
flag = pattern.test(s);
if (!flag) {
return false;
}
return (true);
}
//比较两个数是否相同
function CompValue(s1, s2) {
if (s1 != s2) {
return false;
}
else
return true;
}
//判断字符是否为空
function IsEmpty(s) {
if (s == "") {
return false;
}
else
return true;
}
//取RadioList的值
function GetRadioList(s) {
var radListItems = document.all(s);
var radListItesCount = radListItems.le
相关文档:
event.keycode大全(javascript)
keycode 8 = BackSpace BackSpace
keycode 9 = Tab Tab
keycode 12 = Clear
keycode 13 = Enter
keycode 16 = Shift_L
keycode 17 = Control_L
keycode 18 = Alt_L
keycode 19 = Pause
keycode 20 = Caps_Lock
keycode 27 = Escape Escape
keycode 32 = space space
......
javascript typeof的用法
经常会在js里用到数组,比如 多个名字相同的input, 若是动态生成的, 提交时就需要判断其是否是数组.
if(document.mylist.length != "undefined" ) {} 这个用法有误.
正确的是 if( typeof(document.mylist.length) != "undefined" ) {}
或 if( !isNaN(document.mylist.length) ) {}
typeof的运 ......
JS Check:
javascriptlint http://www.javascriptlint.com/index.htm
jslint http://www.jslint.com/
JS UT:
http://www.jsunit.net/
JS ST:
http://www.outofhanwell.com/ieleak/index.php?title=Main_Page Drip
http://blogs.msdn.com/gpde/pages/javascript-memory-leak-detector.aspx
http://blogs.msdn. ......
Build your web applications quickly and easily using the industry leading web application IDE -- Aptana Studio.
Introduction:
Aptana Studio is a complete web development environment that combines powerful authoring tools for HTML, CSS, and JavaScript, along with thousands of additional plugins ......
//the common event,If your brower is firefox,you should use this function instead of "window.event"
function getEvent() {
if(document.all)
return window.event; //get ie event
func=getEvent.caller;
while(func!=null) {
......