Forums
This topic is locked
Alert Window
Posted 13 Jun 2003 01:34:15
1
has voted
13 Jun 2003 01:34:15 Ken Dobson posted:
Does anyone know how to set an alert window on blur, AFTER comparing two fields? On a registration form, I'm trying to make sure that the username does not match the password. If it does, I want it to come up with an Alert window. I'm must be missing something, as it shouldn't be this hard.Here's my code:
HEAD:
<script type="text/javascript">
function PasswordAlert()
{
alert("Password can not be the same as username"

}
</script>
BODY:
<input name="Password" type="password" id="Password" onBlur="
<%
if Username = password then
PasswordAlert()
end if
%> "
It works fine if I just do a onClick="PasswordAlert()", but there's no compare happening.
Thanks!
Replies
Replied 13 Jun 2003 02:13:20
13 Jun 2003 02:13:20 Phil Shevlin replied:
You can't use server side code to test for a client side event.
You need to use client side code, such as javascript. Check out www.irt.org
You need to use client side code, such as javascript. Check out www.irt.org
Replied 13 Jun 2003 09:04:40
13 Jun 2003 09:04:40 Vince Baker replied:
Insert this in the head of your page and change the form name and field names to match yours.
<script language="VBScript">
Function form1_OnSubmit()
if document.form1.username.value = document.form1.password.value then
alert("Your password must be different to your chosen username"
form1_OnSubmit = false
else
form1_OnSubmit = True
end if
end Function
</script>
Regards
Vince
Visit my home: www.chez-vince.com
VBScript | ASP | HTML | SQL | Oracle | Hosting
<script language="VBScript">
Function form1_OnSubmit()
if document.form1.username.value = document.form1.password.value then
alert("Your password must be different to your chosen username"

form1_OnSubmit = false
else
form1_OnSubmit = True
end if
end Function
</script>
Regards
Vince
Visit my home: www.chez-vince.com
VBScript | ASP | HTML | SQL | Oracle | Hosting
Replied 13 Jun 2003 18:17:55
13 Jun 2003 18:17:55 Ken Dobson replied:
Thanks Vince. It worked like a champ. You rock! Must be from all that Vobster diving. <img src=../images/dmxzone/forum/icon_smile_big.gif border=0 align=middle> Nobody can tell me you suffer from Nitrogen Narcosis. <img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle>
Ken
Ken
Replied 16 Jun 2003 14:13:19
16 Jun 2003 14:13:19 Vince Baker replied:
Your welcome Ken,
Always happy to help.
Regards
Vince
Visit my home: www.chez-vince.com
VBScript | ASP | HTML | SQL | Oracle | Hosting
Always happy to help.
Regards
Vince
Visit my home: www.chez-vince.com
VBScript | ASP | HTML | SQL | Oracle | Hosting