Javascript基本函数文件(去空格、Email格式判断)
来源:互联网 发布:c语言实验正弦信号 编辑:程序博客网 时间:2024/04/30 09:08
一般我在写Javascript文件时把一些最基本的函数写在一个文件里,供其它js文件调用,并命名为base.js
//Wipe off the blank
function trim(str){
return str.replace(/(^/s*)|(/s*$)/g, "");
}
//Check the string ,it should compose with the english , number, "_" or "-"
function isCharacter(str) {
var strRequest = /^([a-zA-Z0-9._-])+/;
if(strRequest.test(str)) {
return true;
}
return false;
}
//Check the email format, it should give the value just like abc_efg@163.com ,the symbol "@" and "." must be contained.
function isEmail(email) {
var emailRequest = /^([a-zA-Z0-9._-])+@([a-zA-Z0-9_-])+(/.[a-zA-Z0-9_-])+/;
if(emailRequest.test(email)) {
return true;
}
return false;
}
//Check the value ,if it empty ,return false
function isEmpty(str) {
str = trim(str);
if(str === null || str === "") {
return true;
}
return false;
}
//The string's length can't larger than the maxLength
function overMaxLeng(str, maxLength) {
var strLeng = str.leng;
if(strLeng > maxLength) {
return true;
}
return false;
}
//The string's length can't less than the minLength
function lessMinLeng(str, minLength) {
var strLeng = str.leng;
if(strLeng < minLength) {
return true;
}
return false;
}
//Wipe off the blank
function trim(str){
return str.replace(/(^/s*)|(/s*$)/g, "");
}
//Check the string ,it should compose with the english , number, "_" or "-"
function isCharacter(str) {
var strRequest = /^([a-zA-Z0-9._-])+/;
if(strRequest.test(str)) {
return true;
}
return false;
}
//Check the email format, it should give the value just like abc_efg@163.com ,the symbol "@" and "." must be contained.
function isEmail(email) {
var emailRequest = /^([a-zA-Z0-9._-])+@([a-zA-Z0-9_-])+(/.[a-zA-Z0-9_-])+/;
if(emailRequest.test(email)) {
return true;
}
return false;
}
//Check the value ,if it empty ,return false
function isEmpty(str) {
str = trim(str);
if(str === null || str === "") {
return true;
}
return false;
}
//The string's length can't larger than the maxLength
function overMaxLeng(str, maxLength) {
var strLeng = str.leng;
if(strLeng > maxLength) {
return true;
}
return false;
}
//The string's length can't less than the minLength
function lessMinLeng(str, minLength) {
var strLeng = str.leng;
if(strLeng < minLength) {
return true;
}
return false;
}
- Javascript基本函数文件(去空格、Email格式判断)
- javascript去空格函数
- javascript去空格函数
- javascript去空格函数
- javascript去空格函数
- JavaScript中字符串去空格的函数
- JAVA 判断EMAIL格式
- 判断EMAIL格式脚本
- 判断回文字符(包含去空格)
- 常用EMAIL格式检验(Javascript)
- javascript去空格
- javascript 去空格
- javascript去空格
- JavaScript 去空格正则
- javascript去空格
- javascript去空格
- JavaScript去空格
- 判断email格式正确与否
- 网站开发规范
- 软件工程师日语---仕様書2
- 使用xampp安装mantis
- OTL简介
- linux 更改启动权限
- Javascript基本函数文件(去空格、Email格式判断)
- 年宵花卉
- 当你已经23岁时(转自朋友)
- MSDN的一个例子 有获取到各种操作系统
- 总线技术太快了
- 透过宏定义了解MFC的消息响应机制
- C# sealed关键字
- 零起点,photoshop cs3 教程
- Symbian中窥探C++编程功底