Subversion Repositories Applications.papyrus

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2150 mathias 1
if(!dojo._hasResource["dojox.validate.us"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2
dojo._hasResource["dojox.validate.us"] = true;
3
dojo.provide("dojox.validate.us");
4
dojo.require("dojox.validate._base");
5
 
6
dojox.validate.us.isState = function(/*String*/value, /*Object?*/flags){
7
	// summary: Validates US state and territory abbreviations.
8
	//
9
	// value: A two character string
10
	// flags: An object
11
	//    flags.allowTerritories  Allow Guam, Puerto Rico, etc.  Default is true.
12
	//    flags.allowMilitary  Allow military 'states', e.g. Armed Forces Europe (AE).  Default is true.
13
 
14
	var re = new RegExp("^" + dojox.regexp.us.state(flags) + "$", "i");
15
	return re.test(value); // Boolean
16
}
17
 
18
dojox.validate.us.isPhoneNumber = function(/*String*/value){
19
	// summary: Validates 10 US digit phone number for several common formats
20
	// value: The telephone number string
21
 
22
	var flags = {
23
		format: [
24
			"###-###-####",
25
			"(###) ###-####",
26
			"(###) ### ####",
27
			"###.###.####",
28
			"###/###-####",
29
			"### ### ####",
30
			"###-###-#### x#???",
31
			"(###) ###-#### x#???",
32
			"(###) ### #### x#???",
33
			"###.###.#### x#???",
34
			"###/###-#### x#???",
35
			"### ### #### x#???",
36
			"##########"
37
		]
38
	};
39
	return dojox.validate.isNumberFormat(value, flags); // Boolean
40
}
41
 
42
dojox.validate.us.isSocialSecurityNumber = function(/*String*/value){
43
	// summary: Validates social security number
44
	var flags = {
45
		format: [
46
			"###-##-####",
47
			"### ## ####",
48
			"#########"
49
		]
50
	};
51
	return dojox.validate.isNumberFormat(value, flags); // Boolean
52
}
53
 
54
dojox.validate.us.isZipCode = function(/*String*/value){
55
	// summary: Validates U.S. zip-code
56
	var flags = {
57
		format: [
58
			"#####-####",
59
			"##### ####",
60
			"#########",
61
			"#####"
62
		]
63
	};
64
	return dojox.validate.isNumberFormat(value, flags); // Boolean
65
}
66
 
67
}