0
javascript to validate a percentage
Contributor
,
/t5/coldfusion-discussions/javascript-to-validate-a-percentage/td-p/192242
Sep 29, 2008
Sep 29, 2008
Copy link to clipboard
Copied
Hello,
Any one knows a way to vaidate that the number entered in text box is either a 1 or a percent. I have been trying to validate this using javascript and its not working.
Please help
Any one knows a way to vaidate that the number entered in text box is either a 1 or a percent. I have been trying to validate this using javascript and its not working.
Please help
TOPICS
Getting started
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/coldfusion-discussions/javascript-to-validate-a-percentage/m-p/192243#M17379
Sep 29, 2008
Sep 29, 2008
Copy link to clipboard
Copied
What did you try and in what way did it not work?
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
umuayo
AUTHOR
Contributor
,
LATEST
/t5/coldfusion-discussions/javascript-to-validate-a-percentage/m-p/192245#M17381
Sep 29, 2008
Sep 29, 2008
Copy link to clipboard
Copied
I have put <cfinput> validate as a float, that took
care of that problem. But now when I validate with the regular
script, it does not return back to the error form. Did I mention
that this is flash forms..
See code below..
<cfsavecontent variable="Test">
var varExpressedAs = displayid.value;
var blnGreaterZero = (rangefloor.text >0)&&(rangeceiling.text >0)
var blnEqualZero = (rangefloor.text==0)&&(rangeceiling.text ==0)
<!--- THE FORM IS SET UP TO VALIDATE ON NUMBERS,
SO NO NEED TO VALIDATE WITH JS HERE --->
<!--- ATLEAST A VALUE HAD TO BE GREATER THAT ZERO --->
if (blnEqualZero)
{
alert('Enter a value in the Range or Celing form!', 'Alert', mx.controls.Alert.OK);
}
if (blnGreaterZero)
{
alert('You can only enter one value in either the Range or Ceiling form', 'Alert', mx.controls.Alert.OK);
}
if (varExpressedAs==1)
{
if ((rangefloor.text > 1)||(rangeceiling.text>1))
{
alert('The values entered has to be greater or eqaul to 1', 'Alert', mx.controls.Alert.OK);
}
}
if (varExpressedAs >1)
{
if ((rangefloor.text < 0)||(rangeceiling.text < 0))
{
alert('The values entered has to be percentages are not allowed', 'Alert', mx.controls.Alert.OK);
}
}
</cfsavecontent>
See code below..
<cfsavecontent variable="Test">
var varExpressedAs = displayid.value;
var blnGreaterZero = (rangefloor.text >0)&&(rangeceiling.text >0)
var blnEqualZero = (rangefloor.text==0)&&(rangeceiling.text ==0)
<!--- THE FORM IS SET UP TO VALIDATE ON NUMBERS,
SO NO NEED TO VALIDATE WITH JS HERE --->
<!--- ATLEAST A VALUE HAD TO BE GREATER THAT ZERO --->
if (blnEqualZero)
{
alert('Enter a value in the Range or Celing form!', 'Alert', mx.controls.Alert.OK);
}
if (blnGreaterZero)
{
alert('You can only enter one value in either the Range or Ceiling form', 'Alert', mx.controls.Alert.OK);
}
if (varExpressedAs==1)
{
if ((rangefloor.text > 1)||(rangeceiling.text>1))
{
alert('The values entered has to be greater or eqaul to 1', 'Alert', mx.controls.Alert.OK);
}
}
if (varExpressedAs >1)
{
if ((rangefloor.text < 0)||(rangeceiling.text < 0))
{
alert('The values entered has to be percentages are not allowed', 'Alert', mx.controls.Alert.OK);
}
}
</cfsavecontent>
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Engaged
,
/t5/coldfusion-discussions/javascript-to-validate-a-percentage/m-p/192244#M17380
Sep 29, 2008
Sep 29, 2008
Copy link to clipboard
Copied
How about trying something along these lines (I am typing
from memory, so do a little bit of homework on the cfinput and the
range features)...
<cfinput type="Text" name="InputField" range=".00, 1.00001">
<cfinput type="Text" name="InputField" range=".00, 1.00001">
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

