Ask a Question related to Coldfusion - Getting Started, Design and Development.
-
rbgerman #1
Easy validation question
hey all,
I am getting an error on my page. It is doing a calculation so the input must
be a number. It throws an error if the number has a comma in it. How can I
avoid this?
ERROR:
An error occurred while evaluating the expression:
paymt=(url.prin)*i/(1-temp)
Error near line 158, column 9.
Cannot convert 100,000 to number.
Please, check the ColdFusion manual for the allowed conversions between data
types
rbgerman Guest
-
VERY easy question (I think!)...
Regarding this page I'm working on: http://al-i.anixter.com/TEMP/SAM/index.html I can't get the text to all be to the right of the pictures. ... -
Easy question, but not for me :)
Hi, I've got a dilemma. I want a Flash-website, but don't really understand how should I implement it. Example: a movie playing in the center and... -
Easy question = easy answer?
Well, so I'm pretty new with Freehand, at the mo running with MX and havin' a problem (not big, but anyway)... I'm creating some cards and they... -
Easy Question ??
Hi Renee, You first want to add the field to the underlying table. Then when you go to your form, the field list will include that new element and... -
Easy Question/Easy Answer
Ok, this is all i want to know how to do, i made a text link, now when someone rolls over it with their pointer i want it to change color. Simple? -
SteveBryant #2
Re: Easy validation question
I wrote a UDF for this purpose which converts valid numbers (numbers with
commas and up to one decimal) to numeric values (at bottom of message). You can
also use the UDF, [url]http://www.cflib.org/udf.cfm?ID=707[/url] to remove all non-numeric
chracters - thereby forcing a numeric value.
Others may recommend val(), but be careful with that for this problem as it
returns the first numeric characters (it would return the numbers *before* the
first comma).
<cfscript>
function convertNumber(strNumber) {
var i = 0;
var tmpVal = "";
var thisChar = "";
var dotCount = 0;
for (i=1; i lte Len(strNumber); i=i+1) {
thisChar = Mid(strNumber, i, 1);
if ( isNumeric(thisChar) OR thisChar eq "." ) {
tmpVal = tmpVal & thisChar;
} else {
if ( thisChar eq "." AND dotCount eq 0 ) {
dotCount = dotCount + 1;
tmpVal = tmpVal & thisChar;
}
}
}
if ( Len(tmpVal) eq 0 ) {
tmpVal = 0;
}
return tmpVal;
}
</cfscript>
SteveBryant Guest
-
Dan Bracuk #3
Re: Easy validation question
It's probably easier to use replace() to get rid of the comma's. If there is any doubt as to whether or not the url variable is a number, isNumeric() can be used to check.
Dan Bracuk Guest
-
SafariTECH #4
Re: Easy validation question
you can also start out with the form so it only accepts a numeric entry using the validation techniques for forms
SafariTECH Guest



Reply With Quote

