Back with validation through javascript......

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Yodai

    Back with validation through javascript......

    Hey.... The validation system that kaeli made works smooth.... Now I was
    wondering if it would be correct to make some variations to it like this:


    -----original kaeli's code-------

    <html>
    <head>
    <title> test </title>
    <script type="text/javascript">
    function checkLogin()
    {
    var a=prompt("enter the password");
    if (a=="noway") writeSuccess();
    else writeFail();
    }
    function writeSuccess()
    {
    document.getEle mentById("write Area").innerHTM L="Success!";
    }
    function writeFail()
    {
    document.getEle mentById("write Area").innerHTM L="Fail!";
    }
    </script>
    </head>

    <body onLoad="checkLo gin()">
    <div id="writeArea"> </div>
    </body>
    </html>


    -------my variations--------

    <html>
    <head>
    <title> test </title>
    <script type="text/javascript">
    function checkLogin()
    {
    myhtml = "thewholelo t of my web page from after <body> and until before
    </body>
    var a=prompt("enter the password");
    if (a=="noway") writeSuccess();
    else writeFail();
    }
    function writeSuccess()
    {
    document.getEle mentById("write Area").innerHTM L= myhtml;
    }
    function writeFail()
    {
    document.getEle mentById("write Area").innerHTM L="Wrong password!!! Reload
    the page";
    }
    </script>
    </head>

    <body onLoad="checkLo gin()">
    <div id="writeArea"> </div>
    </body>
    </html>


    So, you think it's correct? Should I have any kind of consideration since I
    am trying to create a character-like variable that is 16kb wide??

    Cheers!!!

    Yodai


  • kaeli

    #2
    Re: Back with validation through javascript..... .

    In article <TpVMb.2582525$ uj6.6334486@tel enews.teleline. es>,
    yodai@spamnot.m ail.vu enlightened us with...[color=blue]
    > Hey.... The validation system that kaeli made works smooth.... Now I was
    > wondering if it would be correct to make some variations to it like this:
    >[/color]

    You missed a couple things.
    [color=blue]
    >
    > -------my variations--------
    >
    > <script type="text/javascript">
    > function checkLogin()
    > {
    > myhtml = "thewholelo t of my web page from after <body> and until before
    > </body>[/color]

    Forgot end quotes. VERY important. Also a semi-colon is standard.
    var myhtml = "thewholelo t of my web page from after <body> and until
    before</body>";

    Now, you made this variable that is only good in this function. How is
    the other function going to see it?
    That's called SCOPE.
    Either pass the variable to the other functions or make it global by
    putting
    var myhtml;
    before and outside of any functions. (do not redeclare with var in front
    inside a function if you do that)

    [color=blue]
    > var a=prompt("enter the password");
    > if (a=="noway") writeSuccess();[/color]

    So, if you passed the string, it would be
    writeSuccess(my html);
    [color=blue]
    > else writeFail();
    > }
    > function writeSuccess()
    > {
    > document.getEle mentById("write Area").innerHTM L= myhtml;[/color]

    myhtml is not defined in this function.
    If it were passed, it would be, or if it were global, but it is neither.

    The rest looks good. :)
    [color=blue]
    >
    >
    > So, you think it's correct? Should I have any kind of consideration since I
    > am trying to create a character-like variable that is 16kb wide??[/color]

    You are creating a string (not 'character-like'), which as far as I
    know, all variables declared with "var" in javascript are actually
    variants and quite large enough to hold only 16kb.
    I've put a lot more than that in a string when I had to support NN4. *G*

    --
    --
    ~kaeli~
    Is it true that cannibals don't eat clowns because they
    taste funny?



    Comment

    • Alan P

      #3
      Re: Back with validation through javascript..... .

      You have to be careful with your quotation and quote marks!

      "Yodai" <yodai@spamnot. mail.vu> wrote in message
      news:TpVMb.2582 525$uj6.6334486 @telenews.telel ine.es...[color=blue]
      > Hey.... The validation system that kaeli made works smooth.... Now I was
      > wondering if it would be correct to make some variations to it like this:
      >
      >
      > -----original kaeli's code-------
      >
      > <html>
      > <head>
      > <title> test </title>
      > <script type="text/javascript">
      > function checkLogin()
      > {
      > var a=prompt("enter the password");
      > if (a=="noway") writeSuccess();
      > else writeFail();
      > }
      > function writeSuccess()
      > {
      > document.getEle mentById("write Area").innerHTM L="Success!";
      > }
      > function writeFail()
      > {
      > document.getEle mentById("write Area").innerHTM L="Fail!";
      > }
      > </script>
      > </head>
      >
      > <body onLoad="checkLo gin()">
      > <div id="writeArea"> </div>
      > </body>
      > </html>
      >
      >
      > -------my variations--------
      >
      > <html>
      > <head>
      > <title> test </title>
      > <script type="text/javascript">
      > function checkLogin()
      > {
      > myhtml = "thewholelo t of my web page from after <body> and until before
      > </body>
      > var a=prompt("enter the password");
      > if (a=="noway") writeSuccess();
      > else writeFail();
      > }
      > function writeSuccess()
      > {
      > document.getEle mentById("write Area").innerHTM L= myhtml;
      > }
      > function writeFail()
      > {
      > document.getEle mentById("write Area").innerHTM L="Wrong password!!![/color]
      Reload[color=blue]
      > the page";
      > }
      > </script>
      > </head>
      >
      > <body onLoad="checkLo gin()">
      > <div id="writeArea"> </div>
      > </body>
      > </html>
      >
      >
      > So, you think it's correct? Should I have any kind of consideration since[/color]
      I[color=blue]
      > am trying to create a character-like variable that is 16kb wide??
      >
      > Cheers!!!
      >
      > Yodai
      >
      >[/color]


      Comment

      Working...