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

Validations with javaScript

New Here ,
Apr 02, 2007 Apr 02, 2007
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
TOPICS
Server side applications
412
Translate
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 ,
Apr 02, 2007 Apr 02, 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
>


Translate
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
Guide ,
Apr 02, 2007 Apr 02, 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.
Translate
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 ,
Apr 02, 2007 Apr 02, 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
>
Translate
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
New Here ,
Apr 10, 2007 Apr 10, 2007
LATEST
Hi
Good
They did not serve me any of three validations, thank you very much.
Good-bye
Translate
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