?? js_checkform.js
字號(hào):
//--域名查詢js判斷文件
function CheckBodyEn( Field, FieldTitle )
{
var re = new RegExp(/^[\w-]+$/);
if(!re.test(Field.value))
{
alert("\"" + FieldTitle + "\"中只能輸入英文.");
Field.focus();
return false;
}
return true;
}
function CheckOnlyEn( Field, FieldTitle )
{
var re = new RegExp(/^[\w]+$/);
if(!re.test(Field.value))
{
alert("\"" + FieldTitle + "\"中只能輸入英文.");
Field.focus();
return false;
}
return true;
}
function CheckLegalPsw( Field, FieldTitle )
{
var re = new RegExp (/^[\w\!\@\#\$\%\^\*\(\)\_\+\=\-\,\.\<\?\/\{\}\[\]\;\~\"\?\,\\]+$/);
if(!re.test(Field.value))
{
alert("\"" + FieldTitle + "\"不合法.");
Field.focus();
return false;
}
return true;
}
function CheckEnglish( Field, FieldTitle )
{
var Letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890-.";
var i;
var c;
var str;
var b;
b = true;
str = Field.value;
if(str.charAt( 0 )=='-' || str.charAt( 0 )=='.')
{
b = false;
}
else
{
if( str.charAt( str.length - 1 ) == '-' || str.charAt( str.length - 1 ) == '.' )
{
b = false;
}
else
{
if( str.indexOf(".") == -1)
{
b = false;
}
else
{
for( i = 0; i < str.length; i ++ )
{
c = str.charAt( i );
if (Letters.indexOf( c ) < 0)
b = false;
}
}
}
}
if(!b)
{
alert('非法域名。"' + FieldTitle + '"中只能由"a-z","A-Z","0-9","-","."字符組成,且首尾不能為"-","."');
Field.focus();
return false;
}
return true;
}
function CheckEmpty(Field, FieldTitle)
{
if (Field.value == "")
{
alert("請(qǐng)?jiān)赲"" + FieldTitle + "\"一欄中輸入內(nèi)容.");
Field.focus();
return false;
}
return true;
}
function CheckInteger(Field, FieldTitle)
{
if (Field.value != "")
{
for (i = 0; i < Field.value.length; i++)
{
ch = Field.value.charAt(i);
if (ch < '0' || ch > '9') {
alert("\"" + FieldTitle + "\"中只能輸入數(shù)字.");
Field.focus();
return false;
}
}
}
return true;
}
function CheckDate(Field, FieldTitle)
{
if (Field.value != "")
{
for (i = 0; i < Field.value.length; i++)
{
ch = Field.value.charAt(i);
if ((ch < '0' || ch > '9') && ch != '-' ) {
alert("\"" + FieldTitle + "\"中只能輸入日期.");
Field.focus();
return false;
}
}
}
return true;
}
function CheckPhone(Field, FieldTitle)
{
if (Field.value != "")
{
for (i = 0; i < Field.value.length; i++)
{
ch = Field.value.charAt(i);
if ( (ch < '0' || ch > '9') && ch != '-' && ch != '(' && ch != ')' && ch != '_' && ch != '+' && ch != '.' ) {
alert("\"" + FieldTitle + "\"中只能電話號(hào)碼數(shù)字以及(、)、-、_、+、.符號(hào).");
Field.focus();
return false;
}
}
}
return true;
}
function CheckReal(Field, FieldTitle)
{
if (Field.value != "")
{
DotNum = 0;
for (i = 0; i < Field.value.length; i++)
{
ch = Field.value.charAt(i);
if ((ch < '0' || ch > '9') && ch != '.')
{
alert("\"" + FieldTitle + "\"中只能輸入數(shù)字.");
Field.focus();
return false;
}
if (ch == '.')
{
if (DotNum > 0)
{
alert("\"" + FieldTitle + "\"中只能輸入一個(gè)小數(shù)點(diǎn).");
Field.focus();
DotNum++;
return false;
}
}
}
}
return true;
}
function CheckMoney(Field, FieldTitle)
{
if (Field.value != "")
{
DotNum = 0;
for (i = 0; i < Field.value.length; i++)
{
ch = Field.value.charAt(i);
if ((ch < '0' || ch > '9') && ch != '.' && ch != '-')
{
alert("\"" + FieldTitle + "\"中只能輸入數(shù)字.");
Field.focus();
return false;
}
if (ch == '.')
{
if (DotNum > 0)
{
alert("\"" + FieldTitle + "\"中只能輸入一個(gè)小數(shù)點(diǎn).");
Field.focus();
DotNum++;
return false;
}
}
}
}
return true;
}
function CheckMaxLength(Field, MaxLength, FieldTitle)
{
if (Field.value != "")
{
if (Field.value.length > MaxLength)
{
alert("\"" + FieldTitle + "\"中輸入的字符請(qǐng)不要超過" + MaxLength + "字符.");
Field.focus();
return false;
}
}
return true;
}
function CheckMinLength(Field, MinLength, FieldTitle)
{
if (Field.value != "")
{
if (Field.value.length < MinLength)
{
alert("\"" + FieldTitle + "\"中輸入的字符請(qǐng)不要少于" + MinLength + "字符.");
Field.focus();
return false;
}
}
return true;
}
function CheckOption(Field, FieldTitle)
{
for (i = 0; i < Field.length; i++)
if (Field[i].checked)
return true;
alert("請(qǐng)選擇\"" + FieldTitle + "\"中的值.");
return false;
}
//此函數(shù)用于判斷Email地址是否正確
function CheckEmail(Field)
{
// there must be >= 1 character before @, so we
// start looking at character position 1
// (i.e. second character)
var i = 1;
var len = Field.value.length;
if (len > 50)
{
window.alert("email地址長(zhǎng)度不能超過50位!");
return false;
}
pos1 = Field.value.indexOf("@");
pos2 = Field.value.indexOf(".");
pos3 = Field.value.lastIndexOf("@");
pos4 = Field.value.lastIndexOf(".");
//check '@' and '.' is not first or last character
if ((pos1 <= 0)||(pos1 == len-1)||(pos2 <= 0)||(pos2 == len-1))
{
window.alert("請(qǐng)輸入有效的E-mail地址!");
return false;
}
else
{
//check @. or .@
if( (pos1 == pos2 - 1) || (pos1 == pos2 + 1)
|| ( pos1 != pos3 ) //find two @
|| ( pos4 < pos3 ) ) //. should behind the '@'
{
window.alert("請(qǐng)輸入有效的E-mail地址!");
return false;
}
}
return true;
}
function CheckMustLength(Field, MustLength, FieldTitle)
{
if (Field.value != "")
{
if (Field.value.length != MustLength)
{
alert("\"" + FieldTitle + "\"中輸入的值必須是" + MustLength + "位.");
Field.focus();
return false;
}
}
return true;
}
function CheckIntRange(field,prompt,min,max) {
if ( ! CheckInteger(field,prompt) )
return false;
ival = parseInt(field.value);
if ( ival < min || ival > max ) {
alert(prompt + " 只能為 " + min + " 到 " + max + " 之間的數(shù)");
field.focus();
return false;
}
return true;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -