Author: tmjee
Date: Fri May 12 19:55:39 2006
New Revision: 405999

URL: http://svn.apache.org/viewcvs?rev=405999&view=rev
Log:
XW-371
WW-1311
- changed javascript regexp fro validator type of both 'regexp' and
  'stringregexp' from

!field.value.match("..."){

to

field.value.match("...")==null) {

cause field.value.match(..) method returns an array or null if no matching 
exists


Modified:
    
struts/action2/trunk/core/src/main/resources/template/xhtml/form-close-validate.ftl

Modified: 
struts/action2/trunk/core/src/main/resources/template/xhtml/form-close-validate.ftl
URL: 
http://svn.apache.org/viewcvs/struts/action2/trunk/core/src/main/resources/template/xhtml/form-close-validate.ftl?rev=405999&r1=405998&r2=405999&view=diff
==============================================================================
--- 
struts/action2/trunk/core/src/main/resources/template/xhtml/form-close-validate.ftl
 (original)
+++ 
struts/action2/trunk/core/src/main/resources/template/xhtml/form-close-validate.ftl
 Fri May 12 19:55:39 2006
@@ -53,23 +53,22 @@
                 }
             }
             <#elseif validator.validatorType = "regex">
-            if (field.value != null && 
!field.value.match("${validator.expression?js_string}")) {
+            if (field.value != null && 
!field.value.match("${validator.expression?js_string}")==null) {
                 addError(field, error);
                 errors = true;
             }
             <#elseif validator.validatorType = "stringregex">
-                       if (field.value != null && 
!field.value.match(/${validator.regex}/)) {
+                       if (field.value != null && 
field.value.match(/${validator.regex}/)==null) {
                                addError(field, error);
                                errors = true;
                        }
             <#elseif validator.validatorType = "email">
-            if (field.value != null && field.value.length > 0 && 
field.value.match(/[EMAIL 
PROTECTED](com|net|org|info|edu|mil|gov|biz|ws|us|tv|cc|aero|arpa|coop|int|jobs|museum|name|pro|travel|nato|.{2,2})$/gi)
 == null) {
+            if (field.value != null && field.value.length > 0 && 
field.value.match(/\b(^[_A-Za-z0-9-]+(\.[_A-Za-z0-9-]+)*@([A-Za-z0-9-])+(\.[A-Za-z0-9-]+)*((\.[A-Za-z0-9]{2,})|(\.[A-Za-z0-9]{2,}\.[A-Za-z0-9]{2,}))$)\b/gi)==null)
 {
                 addError(field, error);
                 errors = true;
             }
             <#elseif validator.validatorType = "url">
-            <#--if (field.value != null && field.value.length > 0 && 
field.value.match(/[EMAIL 
PROTECTED](com|net|org|info|edu|mil|gov|biz|ws|us|tv|cc|aero|arpa|coop|int|jobs|museum|name|pro|travel|nato|.{2,2})$/gi)
 == null) { -->
-            if (field.value != null && field.value.length > 0 && 
field.value.match(/(^[_A-Za-z0-9-]+(\.[_A-Za-z0-9-]+)*@([A-Za-z0-9-])+(\.[A-Za-z0-9-]+)*((\.com)|(\.net)|(\.org)|(\.info)|(\.edu)|(\.mil)|(\.gov)|(\.biz)|(\.ws)|(\.us)|(\.tv)|(\.cc)|(\.aero)|(\.arpa)|(\.coop)|(\.int)|(\.jobs)|(\.museum)|(\.name)|(\.pro)|(\.travel)|(\.nato)|(\.[A-Za-z0-9]{2,3})|(\.[A-Za-z0-9]{2,3}\.[A-Za-z0-9]{2,3}))$)/gi)
 == null) { 
+            if (field.value != null && field.value.length > 0 && 
field.value.match(/(^(ftp|http|https):\/\/(\.[_A-Za-z0-9-]+)*(@?([A-Za-z0-9-])+)?(\.[A-Za-z0-9-]+)*((\.[A-Za-z0-9]{2,})|(\.[A-Za-z0-9]{2,}\.[A-Za-z0-9]{2,}))(:[0-9]+)?([/A-Za-z0-9?#_-]*)?$)/gi)==null)
 { 
                 addError(field, error);
                 errors = true;
             }


Reply via email to