scripter73
Programmer
Hi,
** PLEASE DON'T GET INTIMIDATED BY THIS POST'S LENGTH. I THINK ITS AN EASY ONE (THOUGH I CAN'T CRACK IT.)
**
I have a form that has 3 radio buttons. The 1st radio button is a minimum value, the 2nd is a maximum value, and the 3rd one has a text box associated with it where the user can enter dollar amounts. (Keep in mind this is a text box.) The values for these radio buttons are held in hidden fields on the form.
When the user clicks Submit, a Javascript validation function is invoked. It checks the following:
1) If the user picked the 3rd radio button, then verify they entered an amount (this works).
2) Compare the 3rd box value with the other two box values.
Condition: (if 3rd box value is < 1st box value) alert user
OR (if the 3rd box value is > 2nd box value) alert user (here's my problem - this isn't working).
Here's my Javascript code:
if (document.payment_form.cc_payment[2].checked)
{
//require text box be filled in
if (document.payment_form.otheramt.value == "" || document.payment_form.otheramt.value == null){
alert("Please enter a dollar amount for payment."
;
return false;
}
//validate text box to make sure it is the right amount
alert("Min amt is " + document.payment_form.min_amt.value);
alert("Max amt is " + document.payment_form.max_amt.value);
alert("Other amt is " + document.payment_form.otheramt.value);
var min_curr = document.payment_form.min_amt.value;(1st radio button value)
var max_curr = document.payment_form.max_amt.value;(2nd radio button value)
var oth_curr = document.payment_form.otheramt.value;(3rd radio button value)
if (oth_curr < min_curr){
alert("Other currency entered is less than the minimum amt due! Please enter another amount."
;
return false;
}
if (oth_curr > max_curr){
alert("Other currency entered exceeds the maximum amount due! Please enter another amount."
;
return false;
}
The problem is even if I force a condition that should trigger the second alert message, I still get the first. That tells me Javascript's not recognizing these values as I've intended.
I'm thinking its because I'm referencing the hidden "text" boxes and these are not considered numeric or floating values. I tried using the parseFloat(), but that doesn't work. I get the same thing.
Any ideas??? Any help is greatly appreciated.
Thanks,
scripter73
Change Your Thinking, Change Your Life.
** PLEASE DON'T GET INTIMIDATED BY THIS POST'S LENGTH. I THINK ITS AN EASY ONE (THOUGH I CAN'T CRACK IT.)
I have a form that has 3 radio buttons. The 1st radio button is a minimum value, the 2nd is a maximum value, and the 3rd one has a text box associated with it where the user can enter dollar amounts. (Keep in mind this is a text box.) The values for these radio buttons are held in hidden fields on the form.
When the user clicks Submit, a Javascript validation function is invoked. It checks the following:
1) If the user picked the 3rd radio button, then verify they entered an amount (this works).
2) Compare the 3rd box value with the other two box values.
Condition: (if 3rd box value is < 1st box value) alert user
OR (if the 3rd box value is > 2nd box value) alert user (here's my problem - this isn't working).
Here's my Javascript code:
if (document.payment_form.cc_payment[2].checked)
{
//require text box be filled in
if (document.payment_form.otheramt.value == "" || document.payment_form.otheramt.value == null){
alert("Please enter a dollar amount for payment."
return false;
}
//validate text box to make sure it is the right amount
alert("Min amt is " + document.payment_form.min_amt.value);
alert("Max amt is " + document.payment_form.max_amt.value);
alert("Other amt is " + document.payment_form.otheramt.value);
var min_curr = document.payment_form.min_amt.value;(1st radio button value)
var max_curr = document.payment_form.max_amt.value;(2nd radio button value)
var oth_curr = document.payment_form.otheramt.value;(3rd radio button value)
if (oth_curr < min_curr){
alert("Other currency entered is less than the minimum amt due! Please enter another amount."
return false;
}
if (oth_curr > max_curr){
alert("Other currency entered exceeds the maximum amount due! Please enter another amount."
return false;
}
The problem is even if I force a condition that should trigger the second alert message, I still get the first. That tells me Javascript's not recognizing these values as I've intended.
I'm thinking its because I'm referencing the hidden "text" boxes and these are not considered numeric or floating values. I tried using the parseFloat(), but that doesn't work. I get the same thing.
Any ideas??? Any help is greatly appreciated.
Thanks,
scripter73
Change Your Thinking, Change Your Life.