4 * Copyright(c) 2006-2007, Ext JS, LLC.
6 * Originally Released Under LGPL - original licence link has changed is not relivant.
9 * <script type="text/javascript">
12 * @class Roo.form.VTypes
13 * Overridable validation definitions. The validations provided are basic and intended to be easily customizable and extended.
16 Roo.form.VTypes = function(){
17 // closure these in so they are only created once.
18 var alpha = /^[a-zA-Z_]+$/;
19 var alphanum = /^[a-zA-Z0-9_]+$/;
20 var email = /^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,24}$/;
21 var url = /^(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
22 var urlWeb = /^((https?):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i
24 // All these messages and functions are configurable
27 * The function used to validate email addresses
28 * @param {String} value The email address
34 * The error text to display when the email validation function returns false
37 emailText : 'This field should be an e-mail address in the format "user@domain.com"',
39 * The keystroke filter mask to be applied on email input
42 emailMask : /[a-z0-9_\.\-@]/i,
45 * The function used to validate URLs
46 * @param {String} value The URL
52 * The funciton used to validate URLs (only allow schemes 'https' and 'http')
53 * @param {String} v The URL
55 urlWeb : function(v) {
56 return urlWeb.test(v);
59 * The error text to display when the url validation function returns false
62 urlText : 'This field should be a URL in the format "http:/'+'/www.domain.com"',
65 * The function used to validate alpha values
66 * @param {String} value The value
72 * The error text to display when the alpha validation function returns false
75 alphaText : 'This field should only contain letters and _',
77 * The keystroke filter mask to be applied on alpha input
80 alphaMask : /[a-z_]/i,
83 * The function used to validate alphanumeric values
84 * @param {String} value The value
86 alphanum : function(v){
87 return alphanum.test(v);
90 * The error text to display when the alphanumeric validation function returns false
93 alphanumText : 'This field should only contain letters, numbers and _',
95 * The keystroke filter mask to be applied on alphanumeric input
98 alphanumMask : /[a-z0-9_]/i