Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    Regular Coder
    Join Date
    Apr 2003
    Location
    Seoul, Korea
    Posts
    329
    Thanks
    0
    Thanked 0 Times in 0 Posts

    alert message when password value is not "1111"

    Code:
    <form action="action.htm" method="post">
    	    	
      <input name="message">
    
      <input name="password">
     			  
      <input type="submit" value=" Edit "> 
    
    </form>
    Let's suppose I have the above code and the correct password value "1111" is required.

    I like to make the following fuctions.

    (1) If a user enters "2222," "3333" or "others" in the password box, it will pop an alert saying "Sorry, Wrong password!."

    (2) If a user enter "1111" in the password box and click the submit button, it will move to action.htm.


    Thanks in Advance
    Last edited by joonstar; 11-11-2004 at 07:56 AM.
    Get my greedy up

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,909
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    <form action="action.htm" method="post" onSubmit="return submitForm(this.Submitbutton)">

    <input type = "text" name="message">

    <input type = "password" name="password">

    <input type="submit" name = "submitbutton" value=" Edit ">

    </form>


    function submitForm(s) { // when submit form button pressed
    var pwd = document.forms[0].password.value;
    if (pwd != 1111) {
    alert ("Wrong Password! Your greedy has given up! ");
    return false;
    }

    I expect you realise that this is very insecure and easily overcome.

    Thanks in advance for not saying "thanks in advance" in future.
    Last edited by Philip M; 11-11-2004 at 07:54 AM.

  • #3
    Regular Coder
    Join Date
    Apr 2003
    Location
    Seoul, Korea
    Posts
    329
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    
    <script>
    function submitForm(s) { // when submit form button pressed
    var pwd = document.forms.password.value;
    if (pwd != 1111) {
    alert ("Wrong Password! Your greedy has given up! ");
    return false;
    }
    </script>
    
    <form action="action.htm" method="post" onSubmit="return submitForm(this.Submitbutton)">
    
    <input type = "text" name="message">
    
    <input type = "password" name="password">
    
    <input type="submit" name = "submitbutton" value=" Edit "> 
    
    </form>
    The above is applying your code. And it's all code in the page.

    When I enter "1111," it moves to action.htm. (This is good.)

    But when I enter "2222," "5555," or "others," it also moves
    to action.cfm without any alert.(This is not good.)

    What's wrong in my applying your code?


    Thanks in advance for not saying "thanks in advance" in future.
    Although I understand your sentence "Your greedy has given up!",
    I don't understand the quote above clearly.(I am not a native speaker of English, and never been in English speaking country)
    Last edited by joonstar; 11-11-2004 at 08:07 AM.
    Get my greedy up

  • #4
    Regular Coder
    Join Date
    Jul 2002
    Posts
    698
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If you use this you migth as well dump the password since one can easily see it in the source in the browser.

    Code:
    <form action="action.htm" method="post" onSubmit="return submitForm(this.Submitbutton)">
    
    <input type = "text" name="message">
    
    <input type = "password" name="password">
    
    <input type="submit" name = "submitbutton" value=" Edit ">
    
    </form>
    
    <script>
    function submitForm(s) { // when submit form button pressed
    var pwd = document.forms[0].password.value;
    if (pwd != 1111) {
    alert ("Wrong Password! Your greedy has given up! ");
    return false;
    }}
    </script>

  • #5
    Regular Coder
    Join Date
    Apr 2003
    Location
    Seoul, Korea
    Posts
    329
    Thanks
    0
    Thanked 0 Times in 0 Posts
    yes, Your code works.
    Thank you.


    Quote Originally Posted by Garadon
    If you use this you migth as well dump the password since one can easily see it in the source in the browser.
    Thanks for your concern.
    I'll use sever-scripting for this.
    But this javascript is needed.
    Get my greedy up

  • #6
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by joonstar
    But this javascript is needed.
    why - to make it easier for hackers to get into the site?
    *keep it simple (TM)

  • #7
    Regular Coder
    Join Date
    Apr 2003
    Location
    Seoul, Korea
    Posts
    329
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by jbot
    why - to make it easier for hackers to get into the site?
    No.
    The javascript will actually be mixed with the server-scripting language.



    I have another question for this.

    let's suppose I have two submit buttons at the same page like the following.
    Code:
    
    <form action="search.cfm">
        <input type="text" name="search" value="">
        <input type="submit" name="searchButton" value=" Search ">
    </form>
    
    <form action="action.htm" method="post" 
          onSubmit="return submitForm(this.Submitbutton)">
    
        <input type = "text" name="message">
    
        <input type = "password" name="password">
    
        <input type="submit" name = "submitbutton" value=" Edit ">
    
    </form>
    
    <script>
    function submitForm(s) { // when submit form button pressed
    var pwd = document.forms[0].password.value;
    if (pwd != 1111) {
    alert ("Wrong Password! Your greedy has given up! ");
    return false;
    }}
    </script>
    The above code doesn't check whether the password is "1111" or not!
    How can I it works?
    Last edited by joonstar; 11-11-2004 at 02:13 PM.
    Get my greedy up

  • #8
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by joonstar
    The javascript will actually be mixed with the server-scripting language.
    the end user will still see it tho. so wot's the point in that?
    *keep it simple (TM)

  • #9
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,909
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    Hello Joonstar,

    You seem to speak English pretty well - and it is hard to become fluent in a
    language if you have not lived in a country which speaks it.

    However, luckily English is a very easy langauge to learn. It must be - here
    where I live little children of five and six years old speak it all the time.

    However, we find your tag "Give my greedy up" amusing as
    it does not make sense in English and has no meaning. I
    guess you have looked up the wrong word in a dictionary.
    This is easy to do - I once asked after a Dutch friend's lawn
    (gazon) instead of his family (gazin). He lived in a flat and was
    rather puzzled.

    The other point - it is not very polite to thank someone in advance
    when you want them to do you a favour - much better to offer thanks
    afterwards. It is thought to be jolly bad form old boy, do you know, a bit
    like showing Muslims the soles of your feet, what? I suspect this is in
    fact the case in any language and any culture.



  • #10
    Regular Coder
    Join Date
    Apr 2003
    Location
    Seoul, Korea
    Posts
    329
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by jbot
    the end user will still see it tho. so wot's the point in that?
    Oh, You're right.

    Although I mix the javascript with server-scripting code, the end user will
    still see it.

    I was confused.

    I have to think again.
    Get my greedy up


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •