javascript验证3
/*
限制输入字符的位数
str是用户输入字符串,len是要限制的位数
----------------------------
*/
function isSmall(str,len){
if (str.length<len){
return(true);
}else{
return(false);
}
}
/*判断两个字符串是否一致
---------------------------------
*/
function isSame(str1,str2){
if (str1==str2){
return(true);
}else{
return(false);
}
}
/*
判断字符串是否为空开始
---------------------------------
*/
function isNotNull(str){
if (str.length==""){
return(false);
}else{
return(true);
}
}
/*
判断是不是手机号码
---------------------------------
*/
function isPhone(str){
reg=/^[0]?13\d{9}$/gi;
reg2=/^[0]?15\d{9}$/gi;
if(!reg.test(str)&&!reg2.test(str)){
return false;
}
return true;
}
/*
判断用户名是否不包含汉字
(用户名不能为汉字,也不准带有特殊字符)
注:
正则表达式.test() 方法用于检测一个字符串是否匹配某个模式
---------------------------------
*/
function notChinese(str){
var reg=/[^A-Za-z0-9_]/g
if (reg.test(str)){
return (false);
}else{
return(true);
}
}
/*
判断是否为日期
----------------------------------
*/
function isDate (theStr) {
var the1st = theStr.indexOf('-');
var the2nd = theStr.lastInde
相关文档:
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
......
1. 长度限制
<script>
function test()
{
if(document.a.b.value.length>50)
{
alert("不能超过50个字符!");
document.a.b.focus();
return false;
}
}
</script>
<form name=a onsubmit="return test()">
<textarea name="b" cols="40" wrap="VIRTUAL" rows="6"></textarea& ......
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 ......
// JScript 文件
/********************************************************/
/*判定返回值为true或false*/
/********************************************************/
//打开一个新链接
function openwindow()
{
//var $j = jQuery.noConflict();
  ......