/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] opposite of onfocus?

I have a javascript that test to make sure the two passwords entered are the same, but right now it does it onkeyup. Is there a way I can make it so that it either checks whenever the field leaves focus, or if they pause for a few seconds? This is what my script looks like now:

[CODE]<input type=”password” name=”password2″ id=”p2″ onKeyUp=”checkPass(‘p1’, ‘p2’)”>
<span id=”status”></span>[/CODE]

[CODE]<script>
function checkPass ( p1, p2 )
{
pass1 = document.getElementById ( p1 ) .value;
pass2 = document.getElementById ( p2 ) .value;
if ( pass1 != pass2 )
{
document.getElementById ( ‘status’ ) .innerHTML = ‘ <img src=images/no.gif align=absmiddle>
<font color=”darkred” face=”Verdana” size=”1″>Passwords do not match.</font>’;
}
else
{
document.getElementById ( ‘status’ ) .innerHTML = ‘ <img src=images/yes.gif align=absmiddle>
<font color=”darkgreen” face=”Verdana” size=”1″>Success!</font>’;
}
}
</script>[/CODE]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@A1ien51Sep 12.2006 — onblur or onchange
Copy linkTweet thisAlerts:
@SaveSheepauthorSep 12.2006 — onchange worked great; thank you!
×

Success!

Help @SaveSheep spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...