Rev | Line | |
---|
[6547] | 1 | function cf_check_content(item, is_mail) { |
---|
| 2 | if (null == item) { |
---|
| 3 | return false; |
---|
| 4 | } |
---|
| 5 | var value = item.value; |
---|
| 6 | if (null == value || 0 == value.length || '' == value) { |
---|
| 7 | return false; |
---|
| 8 | } |
---|
| 9 | if (is_mail) { |
---|
| 10 | return cf_check_mail_content(value); |
---|
| 11 | } |
---|
| 12 | return true; |
---|
| 13 | } |
---|
| 14 | |
---|
| 15 | function cf_check_mail_content(value) { |
---|
| 16 | var atom = '[-a-z0-9!#$%&\'*+\\/=?^_`{|}~]'; // before arobase |
---|
| 17 | var domain = '([a-z0-9]([-a-z0-9]*[a-z0-9]+)?)'; // domain name |
---|
| 18 | var regex; |
---|
| 19 | regex = '^' + atom + '+' + '(\.' + atom + '+)*'; |
---|
| 20 | regex += '@' + '(' + domain + '{1,63}\.)+' + domain + '{2,63}$'; |
---|
| 21 | var reg = new RegExp(regex, 'i'); |
---|
| 22 | if(reg.test(value)) { |
---|
| 23 | return true; |
---|
| 24 | } else { |
---|
| 25 | return false; |
---|
| 26 | } |
---|
| 27 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.