|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
1200+ fellow developers rate and compare features of the top IDEs, like Visual Studio, Eclipse, RAD, Delphi and others, across 13 categories. Enjoy this FREE Download of the IDE User Satisfaction Study by Evans Data Corporation. Download Now!
|
|
#1
|
|||
|
|||
|
Negative Value in Range
I am working with a Coldfusion form and I want to validate a file with a negative and positive range. For example:
Code:
<cfinput range="-90, 90" validate="float" type="text" name="north" maxlength="40" value=""> But this generates the error: Invalid number -90 in range expression! Anyone have any workarounds to this problem? |
|
#2
|
|||
|
|||
|
Try it without a space after the comma between the 2 numbers. But if the range validation that's built in to CF won't take a negative number, then you'll need to write your own Javascript to do the validation.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#3
|
|||
|
|||
|
I ended up having to write my own validation here. You can see the answer below (in Javascript):
Code:
function validateForm () {
for(i=0;i<document.forms[0].elements.length;++i) {
var elem = document.forms[0].elements[i];
if (elem.name == "my_field") {
if((elem.value >= -90) && (elem.value <= 90)) {
}
else {
alert ("Please enter in a value between -90 and 90.");
return false;
}
}
}
myform.submit();
}
Then in the form, I wrote: Code:
<cfform action="get_data.cfm" onSubmit="validateForm(this.form);return false;"> And that seems to work well. Thanks for your help! |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Negative Value in Range |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|