...

View Full Version : "Please, enter your password" & "Are you sure to delete?"



joonstar
04-16-2005, 03:33 AM
<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?."

brandonH
04-16-2005, 05:03 AM
<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!

joonstar
04-16-2005, 05:38 AM
<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.

brandonH
04-16-2005, 06:34 AM
<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.

joonstar
04-16-2005, 08:19 AM
<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!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum