• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

javascript to validate a percentage

Contributor ,
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
TOPICS
Getting started

Views

2.0K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 29, 2008 Sep 29, 2008

Copy link to clipboard

Copied

What did you try and in what way did it not work?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Sep 29, 2008 Sep 29, 2008

Copy link to clipboard

Copied

LATEST
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>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
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">

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation