/    Sign up×
Community /Pin to ProfileBookmark

New to Javascript

Hi,

I am trying to learn Javascript and would appreciate some advice please. I tried to write a simple program to get the user to enter a password and when the button is pressed just check the length of the password to make sure its not less than 4 characters and not more than 8 characters and then output true or false in a text box.

It is not working can anyone help please.

<html>
<head>
<title>Untitled Document</title>

<SCRIPT>
function checkLength(aString)
{
return (aString.length >=4) && (aString.length <=8)
};
</SCRIPT>

</head>

<body>
<FORM NAME = “checker”>

Enter your Password
<INPUT NAME = “aString”
TYPE = “TEXT”
SIZE = 8
VALUE = ”>

<br>
<INPUT TYPE = “button”
VALUE = “Check Password”

ONCLICK = “document.checker.checked.value = function checkLength(document.checker.aString.value)”>

<br><br>

<INPUT NAME = “checked”
TYPE = “text”
VALUE = ”>

</FORM>
</body>
</html>

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@vwphillipsJan 29.2007 — [CODE]
<html>
<head>
<title>Untitled Document</title>

<SCRIPT>
function checkLength(aString)
{
return (aString.length >=4) && (aString.length <=8)
};
</SCRIPT>

</head>

<body>
<FORM NAME = "checker">

Enter your Password
<INPUT NAME = "aString"
type = "TEXT"
size = 8
value = ''>

<br>
<INPUT type = "button"
value = "Check Password"
onclick = "document.checker.checked.value = checkLength(document.checker.aString.value)">

<br><br>
<INPUT name = "checked"
type="text"
value = ''>

</FORM>
</body>
</html>[/CODE]
×

Success!

Help @nigel9097 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.18,
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,
)...