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 5 of 5
  1. #1
    Regular Coder
    Join Date
    Apr 2003
    Location
    Seoul, Korea
    Posts
    329
    Thanks
    0
    Thanked 0 Times in 0 Posts

    "Please, enter your password" & "Are you sure to delete?"

    Code:
    <script type="text/javascript">
    
    function sure(){
    msg = "Are you sure?";
    return confirm(msg);
    }
    
    </script>
    
    <form action="delete.cfm?" method="post" onSubmit="return sure()" >
    
    <input name="passWord"
               value=""
               type="password"
               size="16"
               maxlength="16"> &nbsp;
    
     
    <input type="submit" value=" Password Submit ">
    
    </form>

    If a user click the button, an alert saying "are you sure?" will pop.
    The above code works fine.
    But the above code says "are you sure?" although the user clicks the button without entering anything.


    I like to make like the following.

    If a user click the submit button without any entering, it will say, "please, enter your password!"
    And the user enter enter his password, it will say "Are you sure?."
    Last edited by joonstar; 04-16-2005 at 05:55 AM.
    Get my greedy up

  • #2
    Regular Coder
    Join Date
    Oct 2003
    Location
    on a ship
    Posts
    574
    Thanks
    1
    Thanked 6 Times in 5 Posts
    <script type="text/javascript">

    function sure(){
    if(document.getElementById('passWord').length>=1){
    msg = "Are you sure?";return confirm(msg);}
    else{alert('please insert your password');return false;}

    }

    </script>

    <form action="delete.cfm?" method="post" onSubmit="return sure()" >

    <input name="passWord"
    id='passWord'
    value=""
    type="password"
    size="16"
    maxlength="16"> &nbsp;


    <input type="submit" value=" Password Submit ">

    </form>




    hope this is what you wanted!
    Last edited by brandonH; 04-16-2005 at 05:13 AM. Reason: script change

  • #3
    Regular Coder
    Join Date
    Apr 2003
    Location
    Seoul, Korea
    Posts
    329
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by brandonH
    <script type="text/javascript">

    function sure(){
    if(document.getElementById('passWord').length>=1){
    msg = "Are you sure?";return confirm(msg);}
    else{alert('please insert your password');return false;}

    }

    </script>

    <form action="delete.cfm?" method="post" onSubmit="return sure()" >

    <input name="passWord"
    id='passWord'
    value=""
    type="password"
    size="16"
    maxlength="16"> &nbsp;


    <input type="submit" value=" Password Submit ">

    </form>

    hope this is what you wanted!
    I was very happy when I saw your code because it really looks like what I wanted.

    But It doesn't work fine as I expected.

    The following is the test result of your code.

    (1) if a user clicks the submit button without entering anything,
    It says "please insert your password." it's good.

    (2) if a user clicks the submit button with some entering,
    It also says "please insert your password." no this is not what I wanted.


    It should work like the following.

    (1) if a user clicks the submit button without entering anything,
    It says "please insert your password."

    (2) if auser clicks the submit button with some entering,
    It ask "are you sure?" with yes or no button.

    And if the user clicks "yes," it should go to delete.cfm.
    And if the user clicks "no", it should stay there.
    Get my greedy up

  • #4
    Regular Coder
    Join Date
    Oct 2003
    Location
    on a ship
    Posts
    574
    Thanks
    1
    Thanked 6 Times in 5 Posts

    sorry bout that....

    <script type="text/javascript">

    function sure(){
    if(document.getElementById('passWord').value.length>=1){
    msg = "Are you sure?";return confirm(msg);}
    else{alert('please insert your password');return false;}

    }

    </script>


    I forgot to put the value before the .length
    that should fix that problem.
    I make no attempt at pretending like I'm a professional. I offer help with what knowledge I do have.

  • #5
    Regular Coder
    Join Date
    Apr 2003
    Location
    Seoul, Korea
    Posts
    329
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by brandonH
    <script type="text/javascript">

    function sure(){
    if(document.getElementById('passWord').value.length>=1){
    msg = "Are you sure?";return confirm(msg);}
    else{alert('please insert your password');return false;}

    }

    </script>


    I forgot to put the value before the .length
    that should fix that problem.
    Thank you. it works!
    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
    •