js判断用户输入是否是固定电话或者电话号码

<script type="text/javascript"> 
String.prototype.Trim = function() { 
	var m = this.match(/^\s*(\S+(\s+\S+)*)\s*$/); 
	return (m == null) ? "" : m[1]; 
} 
String.prototype.isMobile = function() { 
	return (/^(?:13\d|15[789])-?\d{5}(\d{3}|\*{3})$/.test(this.Trim())); 
} 
String.prototype.isTel = function() { 
	return (/^(([0\+]\d{2,3}-)?(0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/.test(this.Trim())); 
} 
function chkForm() { 
	var content=document.getElementById("content").value;
	var username=document.getElementById("username").value;
	with(document.form1){ 
	if (tel.value.isMobile()||tel.value.isTel()) { 
		tel.value = tel.value.Trim(); 
		return true; 
	} else { 
		alert("请输入正确的手机号码或电话号码\n\n例如:13916752109或0712-3614072"); 
		tel.focus(); 
		return false; 
	}
} 
} 
</script>
时间: 2024-07-28 14:08:12

js判断用户输入是否是固定电话或者电话号码的相关文章

alertDialog创建登陆界面,判断用户输入

alertDialog创建登陆界面,需要获取用户输入的用户名和密码,获取控件对象的时候不能像主布局文件那样获得, 需要在onClickListener中获取,代码如下: 1 public boolean onOptionsItemSelected(MenuItem item) { 2 // TODO Auto-generated method stub 3 switch(item.getItemId()){ 4 case 1: 5 Intent intent = new Intent(); 6

以写代学:python 数据类型之字符串,判断用户输入的id是否符合要求

字符串操作符 比较操作符:字符串大小按ASCLL码值大小进行比较 切片操作符:[].[:].[::] 成员关系操作符:in.not in 脚本:判断用户输入的id是否符合要求 #!/usr/bin/env python import string #定义字符的范围first_id = string.letters + "_"           //确定首字符的范围all_id = string.digits + first_id         //确定其他字符的范围 #请求用户输入

判断用户输入的邮箱地址是否合法 传说中的正则表达式?

判断用户输入的邮箱地址是否合法 - (BOOL) validateEmail: (NSString *) candidate { NSString *emailRegex = @"[A-Z0-9a-z._%+-][email protected][A-Za-z0-9.-]+\.[A-Za-z]{2,4}"; NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", em

43.编写一个程序,判断用户输入的字符是否是数字,若是数字,则输出“a numerical character”

//1.学习到字符输入 //2.判断字符 #include<iostream> using namespace std; int main() { char a; cout<<"please input a charcter: "<<endl; cin>>a; if(a>'0'&&a<'9') { cout<<"it's a numerical character!"<&l

【shell】Linux shell 之 判断用户输入的变量是否为数字

本文内容:判断用户输入的参数是否为数字 在shell中如何进行计算? 方式一 [[email protected] scripts]# echo $((1+2)) 3 方式二 [[email protected] scripts]# expr 2 + 3 5 [[email protected] scripts]# 注意:使用方式二的时候,要求必须要有间隔.如果使用的是乘法,号必须进行转义写为 \ [[email protected] scripts]# expr 2 * 3 expr: 语法错

js判断用户是否正在滚动滚动条,滚动条滚动是否停止

js智能判断是否可以自动滚动 比如,做一个音乐播放器,边播放,边定位歌词,播放的时候,需要自动定位到播放语句,但是用户去拖动或者滚动div(歌词面板)时,这时就必须停止自动滚动,或者说是不能自动滚动,这个怎么做呢? 如果能时时判断 用户是否在滚动就好了? 或者能够 知道滚动开始 和 结束事件 也行? 可惜均不知道! 目前,仅可以利用的就是div元素的滚动事件,下面是我的实现思路,如何判断用户是否滚动停止? 1.html代码 <div id="panel"> <div

Java小案例——判断用户输入的月份的季节

 要求:  *  根据用户输入的月份来判断该月季节 实现代码: import java.util.Scanner; /** * 要求: * 根据用户输入的月份来判断该月季节 * @author Administration * */ public class JudgeSeason { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("请输入一个

shell整理(29)===判断用户输入可不可以作为变量

(一)题目: 接受一个用户输入,判断这个输入是否可以作为变量 可以作为变量的条件 (1)大小写字母都可以 (2)字母中间可以有数字,但是不能以数字开头 (3)特殊字符除了"_ "其他都不可以作为变量 例如: [[email protected] hushuai]# bash 22.sh Input:1dsf Name is not [[email protected] hushuai]# bash 22.sh Input:=ewr Name is not [[email protect

iOS判断用户输入的银行卡号是否正确

为了打造更好的用户体验,同时减轻服务器端的压力,对于一些如,手机号码,银行卡号,身份证号码判断是否正确是很有必要的 下面是一小段判断银行卡号输入是否正确的代码方法供大家参考 - (void)viewDidLoad { [super viewDidLoad]; NSString *str = @"6226820011200783033"; BOOL isRight = [self checkCardNo:str]; if (!isRight) { UIAlertView *alert =