You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2004/03/09 18:25:41 UTC
cvs commit: jakarta-tapestry/framework/src/org/apache/tapestry/valid UrlValidator.script
hlship 2004/03/09 09:25:41
Modified: framework/src/org/apache/tapestry/valid UrlValidator.script
Log:
[27227] inverted logic in client side UrlValidator.script validation
Revision Changes Path
1.3 +18 -18 jakarta-tapestry/framework/src/org/apache/tapestry/valid/UrlValidator.script
Index: UrlValidator.script
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/valid/UrlValidator.script,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- UrlValidator.script 24 Feb 2004 20:42:33 -0000 1.2
+++ UrlValidator.script 9 Mar 2004 17:25:41 -0000 1.3
@@ -5,10 +5,10 @@
>
-<!--
+<!--
Creates a script for validating that a field is required and/or has a minimum
field length.
-
+
Input symbols:
field, form, validator: As normal for a validation script.
requiredMessage: Message to display if the field is required yet blank.
@@ -16,7 +16,7 @@
urlFormatMessage: Message to display if the field value is not a valid URL.
urlRegexpProtocols: The regexp to check that the protocol is one of the allowed protocols.
urlDisallowedProtocolMessage: Message to display if the field value does not use an allowed protocol.
-
+
-->
<script>
@@ -34,36 +34,36 @@
<let key="function" unique="yes">validate_${field.name}</let>
<body>
- function ${function}() {
+ function ${function}() {
var field = document.${form.name}.${field.name};
- strValue = field.value.replace(/ /g,"");
+ strValue = field.value.replace(/ /g,"");
field.value = strValue;
-
+
<if expression="validator.required">
- if (strValue.length == 0)
+ if (strValue.length == 0)
return validator_invalid_field(field, "${requiredMessage}");
</if>
-
- <if expression="validator.minimumLength">
- if (strValue.length < ${validator.minimumLength})
- return validator_invalid_field(field, "${minimumLengthMessage}");
- </if>
<if-not expression="validator.required">
- if (strValue.length == 0)
+ if (strValue.length == 0)
return true;
</if-not>
- if(!regexpTestUrl(strValue))
+ <if expression="validator.minimumLength">
+ if (strValue.length < ${validator.minimumLength})
+ return validator_invalid_field(field, "${minimumLengthMessage}");
+ </if>
+
+ if(!regexpTestUrl(strValue))
return validator_invalid_field(field, "${urlFormatMessage}");
-
+
<if expression="null != urlRegexpProtocols">
- var protoRegExp = ${urlRegexpProtocols};
- if(!protoRegExp.test(strValue))
+ var protoRegExp = ${urlRegexpProtocols};
+ if(!protoRegExp.test(strValue))
return validator_invalid_field(field, "${urlDisallowedProtocolMessage}");
</if>
- return true;
+ return true;
}
</body>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org