...

View Full Version : alert message when password is wrong.



joonstar
11-11-2004, 08:18 AM
<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

Philip M
11-11-2004, 08:48 AM
<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.

joonstar
11-11-2004, 09:05 AM
<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)

Garadon
11-11-2004, 09:29 AM
If you use this you migth as well dump the password since one can easily see it in the source in the browser.



<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>

joonstar
11-11-2004, 09:42 AM
yes, Your code works.
Thank you.



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.

jbot
11-11-2004, 10:46 AM
But this javascript is needed.

why - to make it easier for hackers to get into the site?

joonstar
11-11-2004, 03:10 PM
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.




<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?

jbot
11-11-2004, 03:47 PM
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?

Philip M
11-11-2004, 05:15 PM
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.


:D

joonstar
11-11-2004, 09:46 PM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum