Skip to main content
Participant
April 2, 2007
Question

Validations with javaScript

  • April 2, 2007
  • 3 replies
  • 414 views
Hi
Since they are?
Good
I am doing a System of Savings bank of lendings and retirement for a web page, then as the base of information I have the available balance of the savings bank, an example is 199998.88, later I verify that the requested amount is minor to the available balance

I have JavaScript's function:
if (document.frm.optTyperequest[1].checked) { //Lendings
if (document.frm.txtAmount.value > 199998.88 * 0.7) {
alert('Requested amount is bigger than the Available Balance. Check his your Field');
document.frm.txtAmount.focus();
return false;
} else { //Retirement
document.frm.txtAmount.value > 199998.88;
alert('Requested amount is bigger than the Available Balance. Check his your Field');
return false;
}
}
Html or Form:
<form action="continue.asp" method="post" name="frm" target="_parent" onSubmit="return ValidateForm()">
<input type="hidden" name="txtidEmployee" value="121">
<input type="hidden" name="txtBalance" value="199998.88">

<table align="center" style="WIDTH: 410px">
<td align="left" colSpan="3" bgcolor="#ffffff"> 
<input type="radio" name="optTyperequest" value="S" checked> Lendings
<input type="radio" name="optTyperequest" value="E"> Retirement
</td>
</table>

Since they are two (2) requests lendings and retirement the first one is Lending and the second one is a retirement, then ME NONE WORKS OF THE TWO, none of the two (2) Validations me works, depending on the functions has to say to me a message that this described previously, and it she follows(continues) to another page and does not serve me, to see that you say to me which is the fault, Been grateful
Thank you
very much
Attentivly Text
This topic has been closed for replies.

3 replies

sukikoAuthor
Participant
April 10, 2007
Hi
Good
They did not serve me any of three validations, thank you very much.
Good-bye
Inspiring
April 2, 2007
sukiko wrote:
> Hi
> Since they are?
> Good
> I am doing a System of Savings bank of lendings and retirement for a web page,
> then as the base of information I have the available balance of the savings
> bank, an example is 199998.88, later I verify that the requested amount is
> minor to the available balance

function ValidateForm(form){
msg= "The requested amount is larger than the available balance.\nCheck
your entry";
if (form.optTyperequest[1].checked && frm.txtAmount.value > 199998.88 *
0.7){
alert(msg);
form.txtAmount.focus();
return false;
}
if(form.optTyperequest[0].checked && frm.txtAmount.value > 199998.88 )
alert(msg);
form.txtAmount.focus();
return false;
}
}
return true;
}

<form action="continue.asp" method="post" name="frm" target="_parent"
onSubmit="return ValidateForm(this)">

Mick

>
> I have JavaScript's function:
> if (document.frm.optTyperequest[1].checked) { //Lendings
> if (document.frm.txtAmount.value > 199998.88 * 0.7) {
> alert('Requested amount is bigger than the Available Balance. Check his your
> Field');
> document.frm.txtAmount.focus();
> return false;
> } else { //Retirement
> document.frm.txtAmount.value > 199998.88;
> alert('Requested amount is bigger than the Available Balance. Check his your
> Field');
> return false;
> }
> }
> Html or Form:
> <form action="continue.asp" method="post" name="frm" target="_parent"
> onSubmit="return ValidateForm()">
> <input type="hidden" name="txtidEmployee" value="121">
> <input type="hidden" name="txtBalance" value="199998.88">
>
> <table align="center" style="WIDTH: 410px">
> <td align="left" colSpan="3" bgcolor="#ffffff"> 
> <input type="radio" name="optTyperequest" value="S" checked> Lendings
> <input type="radio" name="optTyperequest" value="E"> Retirement
> </td>
> </table>
>
> Since they are two (2) requests lendings and retirement the first one is
> Lending and the second one is a retirement, then ME NONE WORKS OF THE TWO, none
> of the two (2) Validations me works, depending on the functions has to say to
> me a message that this described previously, and it she follows(continues) to
> another page and does not serve me, to see that you say to me which is the
> fault, Been grateful
> Thank you
> very much
> Attentivly Text
>
Inspiring
April 2, 2007
Try using parseFloat() around your form values.
Ex: parseFloat(document.frm.txtAmount.value)


"sukiko" <webforumsuser@macromedia.com> wrote in message
news:euqsi8$1sl$1@forums.macromedia.com...
> Hi
> Since they are?
> Good
> I am doing a System of Savings bank of lendings and retirement for a web
> page,
> then as the base of information I have the available balance of the
> savings
> bank, an example is 199998.88, later I verify that the requested amount is
> minor to the available balance
>
> I have JavaScript's function:
> if (document.frm.optTyperequest[1].checked) { //Lendings
> if (document.frm.txtAmount.value > 199998.88 * 0.7) {
> alert('Requested amount is bigger than the Available Balance. Check his
> your
> Field');
> document.frm.txtAmount.focus();
> return false;
> } else { //Retirement
> document.frm.txtAmount.value > 199998.88;
> alert('Requested amount is bigger than the Available Balance. Check his
> your
> Field');
> return false;
> }
> }
> Html or Form:
> <form action="continue.asp" method="post" name="frm" target="_parent"
> onSubmit="return ValidateForm()">
> <input type="hidden" name="txtidEmployee" value="121">
> <input type="hidden" name="txtBalance" value="199998.88">
>
> <table align="center" style="WIDTH: 410px">
> <td align="left" colSpan="3" bgcolor="#ffffff"> 
> <input type="radio" name="optTyperequest" value="S" checked> Lendings
> <input type="radio" name="optTyperequest" value="E"> Retirement
> </td>
> </table>
>
> Since they are two (2) requests lendings and retirement the first one is
> Lending and the second one is a retirement, then ME NONE WORKS OF THE TWO,
> none
> of the two (2) Validations me works, depending on the functions has to say
> to
> me a message that this described previously, and it she follows(continues)
> to
> another page and does not serve me, to see that you say to me which is the
> fault, Been grateful
> Thank you
> very much
> Attentivly Text
>


Günter_Schenk
Inspiring
April 2, 2007
Hi,

it took some time to figure it out, but this modified version of your function works for me -- copy the following function into your document´s <head>...</head> as usual:

<script type="text/javascript" language="javascript">
<!-- start
function ValidateForm(frm) {
$treshhold = 199998.88;
$multiply_by = 0.7;
$a = parseFloat($treshhold);
$b = parseInt(parseFloat($multiply_by));

if (frm.optTyperequest.checked) { //Lendings

if (frm.txtAmount.value > eval($a*$b)){
alert('Requested amount is bigger than the Available Balance. Check his your Field');
document.frm.txtAmount.focus();
return false;
}

else {
frm.txtAmount.value > 199998.88;
alert('Requested amount is smaller than the Available Balance. Check his your Field');
return false;
}

return true;
}
}

// end -->
</script>


... and furthermore replace your...
onSubmit="return ValidateForm()"

with...
onsubmit="return ValidateForm(this);"

At least the calculations work, and your form won´t submit ahead of time.