Windows Vista Forums

Java Script Syntax Problem

  1. #1


    Leona Leal Educator Guest

    Java Script Syntax Problem

    Do not program JScript or Java Script!

    Here is my code:

    <Script Language="JavaScript">

    function ChangeRecord(){
    var boolValid = true;
    if (document.FormA.txtPassWordA <>
    document.FormA.txtPassWordB)}
    var incomplete = "PassWords Do Not Match,
    Please Re-Enter";
    alert(incomplete);
    boolValid = false;}
    }
    </Script>

    <Form Name="FormA">

    <Input Type="PassWord" Name="txtPassWordA" Size="40"><br><br>
    <Input Type="PassWord" Name="txtPassWordB" Size="40"><br><br>

    <Input Type="Button" Value="Change Information" Name="B1"
    OnClick="ChangeRecord();">

    When I click on the Button, I get Error On Page.

    What am I doing wrong.

    My colleague entered this earlier, but under JScript. He did not get a
    response as of this time.

    Thanks

    Granny Leona

      My System SpecsSystem Spec

  2.   


  3. #2


    Tom Lavedas Guest

    Re: Java Script Syntax Problem

    On Jan 15, 5:26*pm, Leona Leal Educator
    <LeonaLealEduca...@xxxxxx> wrote:

    > Do not program JScript or Java Script!
    >
    > Here is my code:
    >
    > <Script Language="JavaScript">
    >
    > * * * * * * * * function ChangeRecord(){
    > * * * * * * * * var boolValid = true;
    > * * * * * * * * * * * * * * * * if (document.FormA.txtPassWordA <>
    > document.FormA.txtPassWordB)}
    > * * * * * * * * * * * * * * * * var incomplete = "PassWords Do Not Match,
    > Please Re-Enter";
    > * * * * * * * * * * * * * * * * alert(incomplete);
    > * * * * * * * * boolValid = false;}}
    >
    > </Script>
    >
    > <Form Name="FormA">
    >
    > <Input Type="PassWord" Name="txtPassWordA" Size="40"><br><br>
    > <Input Type="PassWord" Name="txtPassWordB" Size="40"><br><br>
    >
    > <Input Type="Button" Value="Change Information" Name="B1"
    > OnClick="ChangeRecord();">
    >
    > When I click on the Button, I get Error On Page.
    >
    > What am I doing wrong.
    >
    > My colleague entered this earlier, but under JScript. *He did not get a
    > response as of this time.
    >
    > Thanks
    >
    > Granny Leona
    Your script has two errors. One is a typo, the other a substantial
    lack of understanding of JScript.

    The typo is that the closing curly bracket on this line should be an
    open curly bracket ...

    if (document.FormA.txtPassWordA <> document.FormA.txtPassWordB)}

    The syntax error is on the same line. The not equal operator in
    JScript is !==, not <>. This is the same as in C, C++, Java, etc.

    So, try this ...

    <Script Language="JavaScript">

    function ChangeRecord()
    {
    var boolValid = true;
    if (document.FormA.txtPassWordA !== document.FormA.txtPassWordB)
    {
    var incomplete = "PassWords Do Not Match, Please Re-Enter";
    alert(incomplete);
    boolValid = false;
    }
    }

    </Script>

    I reformatted the layout a bit to make it more readable, I think.

    BTW, why are you asking this question in a VBScript group?

    Tom Lavedas
    ***********
    http://there.is.no.more/tglbatch/

      My System SpecsSystem Spec

  4. #3


    Leona Leal Educator Guest

    Re: Java Script Syntax Problem

    I put it here because my associate put it in JScript this AM. He did not get
    a response and I had trouble bringing JScript up.

    Our district is off and on a military base, most of the software was written
    in Assembler.

    Why, I do not know, but it is very good, but very old.

    Thanks for helping us out!

    Granny

    "Tom Lavedas" wrote:

    > On Jan 15, 5:26 pm, Leona Leal Educator
    > <LeonaLealEduca...@xxxxxx> wrote:

    > > Do not program JScript or Java Script!
    > >
    > > Here is my code:
    > >
    > > <Script Language="JavaScript">
    > >
    > > function ChangeRecord(){
    > > var boolValid = true;
    > > if (document.FormA.txtPassWordA <>
    > > document.FormA.txtPassWordB)}
    > > var incomplete = "PassWords Do Not Match,
    > > Please Re-Enter";
    > > alert(incomplete);
    > > boolValid = false;}}
    > >
    > > </Script>
    > >
    > > <Form Name="FormA">
    > >
    > > <Input Type="PassWord" Name="txtPassWordA" Size="40"><br><br>
    > > <Input Type="PassWord" Name="txtPassWordB" Size="40"><br><br>
    > >
    > > <Input Type="Button" Value="Change Information" Name="B1"
    > > OnClick="ChangeRecord();">
    > >
    > > When I click on the Button, I get Error On Page.
    > >
    > > What am I doing wrong.
    > >
    > > My colleague entered this earlier, but under JScript. He did not get a
    > > response as of this time.
    > >
    > > Thanks
    > >
    > > Granny Leona
    >
    > Your script has two errors. One is a typo, the other a substantial
    > lack of understanding of JScript.
    >
    > The typo is that the closing curly bracket on this line should be an
    > open curly bracket ...
    >
    > if (document.FormA.txtPassWordA <> document.FormA.txtPassWordB)}
    >
    > The syntax error is on the same line. The not equal operator in
    > JScript is !==, not <>. This is the same as in C, C++, Java, etc.
    >
    > So, try this ...
    >
    > <Script Language="JavaScript">
    >
    > function ChangeRecord()
    > {
    > var boolValid = true;
    > if (document.FormA.txtPassWordA !== document.FormA.txtPassWordB)
    > {
    > var incomplete = "PassWords Do Not Match, Please Re-Enter";
    > alert(incomplete);
    > boolValid = false;
    > }
    > }
    >
    > </Script>
    >
    > I reformatted the layout a bit to make it more readable, I think.
    >
    > BTW, why are you asking this question in a VBScript group?
    >
    > Tom Lavedas
    > ***********
    > http://there.is.no.more/tglbatch/
    >

      My System SpecsSystem Spec

  5. #4


    Leona Leal Educator Guest

    Re: Java Script Syntax Problem

    Tom;

    Thanks for getting back to me, but it is better, but still not working. I
    get the message that the password are not equal even if they are:

    Current Code:

    <Script Language="JavaScript">
    function ChangeRecord(){

    var boolValid=true;

    if (document.forms.txtPasswordA !== document.forms.txtPasswordB)
    {
    var incomplete = "PassWords Do Not Match, Please Re-Enter!";
    alert(incomplete);
    boolValid = false;
    }

    if (boolValid==true)
    {
    document.FormA.action = "NewMemB.Asp";
    document.FormA.submit();
    }
    }

    </Script>

    Password <Input Type="PassWord" Name="txtPasswordA" Size="10"
    MaxLength="11"><%Response.Write Sp04%>
    Retype Password<%Response.Write Sp04%><Input Type="PassWord"
    Name="txtPasswordB" Size="10" MaxLength="11">

    <Input Type="Button" Value="Update Information" Name="B3"
    OnClick="ChangeRecord()">

    Thanks Again

    "Leona Leal Educator" wrote:

    > I put it here because my associate put it in JScript this AM. He did not get
    > a response and I had trouble bringing JScript up.
    >
    > Our district is off and on a military base, most of the software was written
    > in Assembler.
    >
    > Why, I do not know, but it is very good, but very old.
    >
    > Thanks for helping us out!
    >
    > Granny
    >
    > "Tom Lavedas" wrote:
    >

    > > On Jan 15, 5:26 pm, Leona Leal Educator
    > > <LeonaLealEduca...@xxxxxx> wrote:

    > > > Do not program JScript or Java Script!
    > > >
    > > > Here is my code:
    > > >
    > > > <Script Language="JavaScript">
    > > >
    > > > function ChangeRecord(){
    > > > var boolValid = true;
    > > > if (document.FormA.txtPassWordA <>
    > > > document.FormA.txtPassWordB)}
    > > > var incomplete = "PassWords Do Not Match,
    > > > Please Re-Enter";
    > > > alert(incomplete);
    > > > boolValid = false;}}
    > > >
    > > > </Script>
    > > >
    > > > <Form Name="FormA">
    > > >
    > > > <Input Type="PassWord" Name="txtPassWordA" Size="40"><br><br>
    > > > <Input Type="PassWord" Name="txtPassWordB" Size="40"><br><br>
    > > >
    > > > <Input Type="Button" Value="Change Information" Name="B1"
    > > > OnClick="ChangeRecord();">
    > > >
    > > > When I click on the Button, I get Error On Page.
    > > >
    > > > What am I doing wrong.
    > > >
    > > > My colleague entered this earlier, but under JScript. He did not get a
    > > > response as of this time.
    > > >
    > > > Thanks
    > > >
    > > > Granny Leona
    > >
    > > Your script has two errors. One is a typo, the other a substantial
    > > lack of understanding of JScript.
    > >
    > > The typo is that the closing curly bracket on this line should be an
    > > open curly bracket ...
    > >
    > > if (document.FormA.txtPassWordA <> document.FormA.txtPassWordB)}
    > >
    > > The syntax error is on the same line. The not equal operator in
    > > JScript is !==, not <>. This is the same as in C, C++, Java, etc.
    > >
    > > So, try this ...
    > >
    > > <Script Language="JavaScript">
    > >
    > > function ChangeRecord()
    > > {
    > > var boolValid = true;
    > > if (document.FormA.txtPassWordA !== document.FormA.txtPassWordB)
    > > {
    > > var incomplete = "PassWords Do Not Match, Please Re-Enter";
    > > alert(incomplete);
    > > boolValid = false;
    > > }
    > > }
    > >
    > > </Script>
    > >
    > > I reformatted the layout a bit to make it more readable, I think.
    > >
    > > BTW, why are you asking this question in a VBScript group?
    > >
    > > Tom Lavedas
    > > ***********
    > > http://there.is.no.more/tglbatch/
    > >

      My System SpecsSystem Spec

  6. #5


    Leona Leal Educator Guest

    Re: Java Script Syntax Problem

    I GOOFED, TRYING SO MANY THINGS, THAT I SUBMITTED A TYPO!

    "Leona Leal Educator" wrote:

    > Tom;
    >
    > Thanks for getting back to me, but it is better, but still not working. I
    > get the message that the password are not equal even if they are:
    >
    > Current Code:
    >
    > <Script Language="JavaScript">
    > function ChangeRecord(){
    >
    > var boolValid=true;
    >
    > if (document.FormA.txtPasswordA !== document.FormA.txtPasswordB)
    > {
    > var incomplete = "PassWords Do Not Match, Please Re-Enter!";
    > alert(incomplete);
    > boolValid = false;
    > }
    >
    > if (boolValid==true)
    > {
    > document.FormA.action = "NewMemB.Asp";
    > document.FormA.submit();
    > }
    > }
    >
    > </Script>
    <form name="FormA">

    > Password <Input Type="PassWord" Name="txtPasswordA" Size="10"
    > MaxLength="11"><%Response.Write Sp04%>
    > Retype Password<%Response.Write Sp04%><Input Type="PassWord"
    > Name="txtPasswordB" Size="10" MaxLength="11">
    >
    > <Input Type="Button" Value="Update Information" Name="B3"
    > OnClick="ChangeRecord()">
    >
    > Thanks Again
    >
    > "Leona Leal Educator" wrote:
    >

    > > I put it here because my associate put it in JScript this AM. He did not get
    > > a response and I had trouble bringing JScript up.
    > >
    > > Our district is off and on a military base, most of the software was written
    > > in Assembler.
    > >
    > > Why, I do not know, but it is very good, but very old.
    > >
    > > Thanks for helping us out!
    > >
    > > Granny
    > >
    > > "Tom Lavedas" wrote:
    > >

    > > > On Jan 15, 5:26 pm, Leona Leal Educator
    > > > <LeonaLealEduca...@xxxxxx> wrote:
    > > > > Do not program JScript or Java Script!
    > > > >
    > > > > Here is my code:
    > > > >
    > > > > <Script Language="JavaScript">
    > > > >
    > > > > function ChangeRecord(){
    > > > > var boolValid = true;
    > > > > if (document.FormA.txtPassWordA <>
    > > > > document.FormA.txtPassWordB)}
    > > > > var incomplete = "PassWords Do Not Match,
    > > > > Please Re-Enter";
    > > > > alert(incomplete);
    > > > > boolValid = false;}}
    > > > >
    > > > > </Script>
    > > > >
    > > > > <Form Name="FormA">
    > > > >
    > > > > <Input Type="PassWord" Name="txtPassWordA" Size="40"><br><br>
    > > > > <Input Type="PassWord" Name="txtPassWordB" Size="40"><br><br>
    > > > >
    > > > > <Input Type="Button" Value="Change Information" Name="B1"
    > > > > OnClick="ChangeRecord();">
    > > > >
    > > > > When I click on the Button, I get Error On Page.
    > > > >
    > > > > What am I doing wrong.
    > > > >
    > > > > My colleague entered this earlier, but under JScript. He did not get a
    > > > > response as of this time.
    > > > >
    > > > > Thanks
    > > > >
    > > > > Granny Leona
    > > >
    > > > Your script has two errors. One is a typo, the other a substantial
    > > > lack of understanding of JScript.
    > > >
    > > > The typo is that the closing curly bracket on this line should be an
    > > > open curly bracket ...
    > > >
    > > > if (document.FormA.txtPassWordA <> document.FormA.txtPassWordB)}
    > > >
    > > > The syntax error is on the same line. The not equal operator in
    > > > JScript is !==, not <>. This is the same as in C, C++, Java, etc.
    > > >
    > > > So, try this ...
    > > >
    > > > <Script Language="JavaScript">
    > > >
    > > > function ChangeRecord()
    > > > {
    > > > var boolValid = true;
    > > > if (document.FormA.txtPassWordA !== document.FormA.txtPassWordB)
    > > > {
    > > > var incomplete = "PassWords Do Not Match, Please Re-Enter";
    > > > alert(incomplete);
    > > > boolValid = false;
    > > > }
    > > > }
    > > >
    > > > </Script>
    > > >
    > > > I reformatted the layout a bit to make it more readable, I think.
    > > >
    > > > BTW, why are you asking this question in a VBScript group?
    > > >
    > > > Tom Lavedas
    > > > ***********
    > > > http://there.is.no.more/tglbatch/
    > > >

      My System SpecsSystem Spec

  7. #6


    Antonette Guest

    Re: Java Script Syntax Problem

    Leona;

    You need to tell Java that the field has a value.

    Change to:

    if (document.FormA.txtPasswordA.value != document.FormA.txtPasswordB.value)

    I am sure it will work.

    Good Luck

    Toni

    "Leona Leal Educator" wrote:

    > I GOOFED, TRYING SO MANY THINGS, THAT I SUBMITTED A TYPO!
    >
    > "Leona Leal Educator" wrote:
    >

    > > Tom;
    > >
    > > Thanks for getting back to me, but it is better, but still not working. I
    > > get the message that the password are not equal even if they are:
    > >
    > > Current Code:
    > >
    > > <Script Language="JavaScript">
    > > function ChangeRecord(){
    > >
    > > var boolValid=true;
    > >
    > > if (document.FormA.txtPasswordA !== document.FormA.txtPasswordB)
    > > {
    > > var incomplete = "PassWords Do Not Match, Please Re-Enter!";
    > > alert(incomplete);
    > > boolValid = false;
    > > }
    > >
    > > if (boolValid==true)
    > > {
    > > document.FormA.action = "NewMemB.Asp";
    > > document.FormA.submit();
    > > }
    > > }
    > >
    > > </Script>
    >
    > <form name="FormA">
    >

    > > Password <Input Type="PassWord" Name="txtPasswordA" Size="10"
    > > MaxLength="11"><%Response.Write Sp04%>
    > > Retype Password<%Response.Write Sp04%><Input Type="PassWord"
    > > Name="txtPasswordB" Size="10" MaxLength="11">
    > >
    > > <Input Type="Button" Value="Update Information" Name="B3"
    > > OnClick="ChangeRecord()">
    > >
    > > Thanks Again
    > >
    > > "Leona Leal Educator" wrote:
    > >

    > > > I put it here because my associate put it in JScript this AM. He did not get
    > > > a response and I had trouble bringing JScript up.
    > > >
    > > > Our district is off and on a military base, most of the software was written
    > > > in Assembler.
    > > >
    > > > Why, I do not know, but it is very good, but very old.
    > > >
    > > > Thanks for helping us out!
    > > >
    > > > Granny
    > > >
    > > > "Tom Lavedas" wrote:
    > > >
    > > > > On Jan 15, 5:26 pm, Leona Leal Educator
    > > > > <LeonaLealEduca...@xxxxxx> wrote:
    > > > > > Do not program JScript or Java Script!
    > > > > >
    > > > > > Here is my code:
    > > > > >
    > > > > > <Script Language="JavaScript">
    > > > > >
    > > > > > function ChangeRecord(){
    > > > > > var boolValid = true;
    > > > > > if (document.FormA.txtPassWordA <>
    > > > > > document.FormA.txtPassWordB)}
    > > > > > var incomplete = "PassWords Do Not Match,
    > > > > > Please Re-Enter";
    > > > > > alert(incomplete);
    > > > > > boolValid = false;}}
    > > > > >
    > > > > > </Script>
    > > > > >
    > > > > > <Form Name="FormA">
    > > > > >
    > > > > > <Input Type="PassWord" Name="txtPassWordA" Size="40"><br><br>
    > > > > > <Input Type="PassWord" Name="txtPassWordB" Size="40"><br><br>
    > > > > >
    > > > > > <Input Type="Button" Value="Change Information" Name="B1"
    > > > > > OnClick="ChangeRecord();">
    > > > > >
    > > > > > When I click on the Button, I get Error On Page.
    > > > > >
    > > > > > What am I doing wrong.
    > > > > >
    > > > > > My colleague entered this earlier, but under JScript. He did not get a
    > > > > > response as of this time.
    > > > > >
    > > > > > Thanks
    > > > > >
    > > > > > Granny Leona
    > > > >
    > > > > Your script has two errors. One is a typo, the other a substantial
    > > > > lack of understanding of JScript.
    > > > >
    > > > > The typo is that the closing curly bracket on this line should be an
    > > > > open curly bracket ...
    > > > >
    > > > > if (document.FormA.txtPassWordA <> document.FormA.txtPassWordB)}
    > > > >
    > > > > The syntax error is on the same line. The not equal operator in
    > > > > JScript is !==, not <>. This is the same as in C, C++, Java, etc.
    > > > >
    > > > > So, try this ...
    > > > >
    > > > > <Script Language="JavaScript">
    > > > >
    > > > > function ChangeRecord()
    > > > > {
    > > > > var boolValid = true;
    > > > > if (document.FormA.txtPassWordA !== document.FormA.txtPassWordB)
    > > > > {
    > > > > var incomplete = "PassWords Do Not Match, Please Re-Enter";
    > > > > alert(incomplete);
    > > > > boolValid = false;
    > > > > }
    > > > > }
    > > > >
    > > > > </Script>
    > > > >
    > > > > I reformatted the layout a bit to make it more readable, I think.
    > > > >
    > > > > BTW, why are you asking this question in a VBScript group?
    > > > >
    > > > > Tom Lavedas
    > > > > ***********
    > > > > http://there.is.no.more/tglbatch/
    > > > >

      My System SpecsSystem Spec


Java Script Syntax Problem
Similar Threads
Thread Forum
Install flash player (done! ) then java script..where..how?? Vista General
Java script alert color issue General Discussion
Move computer in AD based on DSQUERY script syntax help! VB Script
Example of a script converted to HTML with syntax highlighting PowerShell
Time Java script Vista security