/    Sign up×
Community /Pin to ProfileBookmark

trying to validate prompt

[CODE]function changeSize()
{
var newSize = prompt(“Please enter size between 10 and 20″);
if (newSize => 10 && newSize <= 20)
{
document.body.style.fontSize = newSize;
}
else
{
return false;
}
}

<input type=”button” value=”Enter Size” name=”size” onclick=”changeSize()” />[/CODE]

its supposed to change the documents font size using a prompt – as long as the input is between 10 and 20. but im getting error “object expected”

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@BuilderQMar 25.2007 — [CODE]newSize => 10[/CODE] should be [CODE]newSize >= 10[/CODE] Also, unless you append a unit onto the inputted font size, it will only work in Internet Explorer.
Copy linkTweet thisAlerts:
@mr_newbieauthorMar 25.2007 — thanks, it works now.

Also, unless you append a unit onto the inputted font size, it will only work in Internet Explorer.[/QUOTE]

what units are there for fontSize? and how would i include it to the function?
Copy linkTweet thisAlerts:
@BuilderQMar 25.2007 — Font size can be defined used the standard CSS units (px, pt, em...), and can be set like so: [CODE]document.body.style.fontSize = newSize+'px';[/CODE]
×

Success!

Help @mr_newbie 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.27,
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,
)...