You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ca...@apache.org on 2007/02/10 14:43:17 UTC
svn commit: r505687 -
/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/clientvalidation/validationscript/resource/validators.js
Author: cagatay
Date: Sat Feb 10 05:43:17 2007
New Revision: 505687
URL: http://svn.apache.org/viewvc?view=rev&rev=505687
Log:
javascript parseInt() for stuff like "12gtre" returns 12 so add a check using a regexp instead
Modified:
myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/clientvalidation/validationscript/resource/validators.js
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/clientvalidation/validationscript/resource/validators.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/clientvalidation/validationscript/resource/validators.js?view=diff&rev=505687&r1=505686&r2=505687
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/clientvalidation/validationscript/resource/validators.js (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/clientvalidation/validationscript/resource/validators.js Sat Feb 10 05:43:17 2007
@@ -25,12 +25,14 @@
if( value != null ) {
//TODO trim
if( value.length > 0) {
- convertedValue = parseInt( value );
- if( isNaN( convertedValue) ) {
- facesMessage = tomahawk.MessageUtils.getMessage(tomahawk.FacesMessage.SEVERITY_ERROR,this.CONVERSION_MESSAGE_ID,new Array(uiinput.id,value))
+ var integerRegExp = /(^-?\d\d*$)/;
+ var isInteger = integerRegExp.test(value);
+ if( !isInteger ) {
+ var facesMessage = tomahawk.MessageUtils.getMessage(tomahawk.FacesMessage.SEVERITY_ERROR,this.CONVERSION_MESSAGE_ID,new Array(uiinput.id,value))
throw new tomahawk.ConverterException( facesMessage );
}
else {
+ var convertedValue = parseInt( value );
return convertedValue;
}
}