/    Sign up×
Community /Pin to ProfileBookmark

I’m Trying To Make A Function That Will Check If You Have A

Value More Than a Certain Number You’ll Get a Pop-up Saying,
“You Don’t Have Enough To Enter That Much Right Now!”.

But When I Check My Function, Which goes something like

This…
<html>
<script language=’javascript’ type=text/javascript’>
<!– Begin
function Take_value()
{
Value = document.Form1.Text1.value;
if (value >= ‘1000’)
alert(‘You Don’t Have Enough To Enter That Much Right Now!’);
else
alert(‘You Took Out ‘ + Value);
}
end –>
</script>
<form name=Form1>
<input type=’text’ name=’Text1′>
<input type=’BUTTON’ value=’Submit’ onClick=Take_value()>
</html>

It Says You Dont Have Enough To Enter That Much Right now!

When I Enter 200.

Can Anyone Out There Help Me? If You Can Please Show Me

a Example Script That Might Work For Me…

to post a comment
JavaScript

14 Comments(s)

Copy linkTweet thisAlerts:
@SlankenOgenJun 26.2003 — [b]Value[/b] = document.Form1.Text1.value;

if ([b]value[/b] >= '1000')

Value should have a capital V in both cases.

~mgb
Copy linkTweet thisAlerts:
@pyroJun 26.2003 — [i]Originally posted by SlankenOgen [/i]

[B][b]Value[/b] = document.Form1.Text1.value;

if ([b]value[/b] >= '1000')



Value should have a capital V in both cases.



~mgb [/B]
[/QUOTE]
Or, if you want to follow common coding practices, make them both lowercase, instead.
Copy linkTweet thisAlerts:
@petermar30030authorJun 26.2003 — I Already Tried That But When I Type In 20 It Gives The Alert Message Saying 'You Don't have enough.?
Copy linkTweet thisAlerts:
@pyroJun 26.2003 — Are you trying to validate the length of the message? If so, I think this is what you are looking for:

value = document.Form1.Text1.length;
Copy linkTweet thisAlerts:
@VladdyJun 26.2003 — You are comparing string to a string:

if (value >= '1000')

when you should be comparing number to a number:

if(parseInt(value) >= 1000)
Copy linkTweet thisAlerts:
@SlankenOgenJun 26.2003 — Best to get rid of the word value altogether. I NEVER use nothin that remotely resembles a keyword or even a html tag. It's just asking for trouble. Use a word like 'money' or something that is positively neutral.

~mgb
Copy linkTweet thisAlerts:
@petermar30030authorJun 26.2003 — I Don't Think I Made My Problem Clear Enough,

My Problem Is That When I Type In A Number Such as 20 Or 200 When The Allowed Value is 1000 Then I Get That Message saying you dont have enough.

I Think The Problem Is that The First Number Of What I Typed In Was 2 When The Function's First Number Is 1, Maby Now You Can Help Me a little Better.?
Copy linkTweet thisAlerts:
@SlankenOgenJun 26.2003 — This works-

<html>

<script type = "text/javascript">

[b]var money = 0;[/b]

function Take_value()

{

money = document.Form1.Text1.value;

if (money >= 1000)

{

alert("You Don't Have Enough To Enter That Much Right Now!");

}

else

{

alert("You Took Out" + money);

}

}

</script>

</head>

<body>

<form name="Form1">

<input type="text" name="Text1">

<input type="BUTTON" value="Submit" onClick="Take_value()">

</form>

</body>

</html>

You should declare the existence of the money/Value variable then give it a value.

~mgb
Copy linkTweet thisAlerts:
@SlankenOgenJun 26.2003 — For the sake of completeness...

<html>

<script type = "text/javascript">

var money = 0;

function Take_value()

{

money = document.Form1.Text1.value;

if(isNaN(money) || money == "")

{

alert("Please enter a numerical amount.");

document.Form1.Text1.value = "";

document.Form1.Text1.focus();

return;

}

if (money >= 1000)

{

alert("You Don't Have Enough To Enter That Much Right Now!");

}

else

{

alert("You Took Out" + money);

}

}

</script>

</head>

<body>

<form name="Form1">

<input type="text" name="Text1">

<input type="BUTTON" value="Submit" onClick=Take_value()>

</form>

</body>

</html>

~mgb
Copy linkTweet thisAlerts:
@petermar30030authorJun 26.2003 — -SlankenOgen

That Worked Preety Well But Do You Think You Can Make A Function That Would Store the money...

I Already Have One But it's fairly Long and mabey you could create a script that smaller than one-hundred lines.

[B]Thanks in Advance[/B] ?
Copy linkTweet thisAlerts:
@SlankenOgenJun 26.2003 — var moneyStore = new Array();

var cntr = -1;

function Take_value(){

.

.

.else

{

alert("You Took Out" + money);

moneyStore[++cntr] = money;

}

.

.

.

}

This will store the money values in an array. Use window.alert(moneyStore);

to check it.

~mgb
Copy linkTweet thisAlerts:
@petermar30030authorJun 26.2003 — Thanks!

You Helped Me Out Alot!
Copy linkTweet thisAlerts:
@SlankenOgenJun 26.2003 — You're welcome.

~mgb
Copy linkTweet thisAlerts:
@petermar30030authorJun 26.2003 — Do You Think You Can Put That All Together So That When I Run It Will Do All Of This , If You Do Please Include A 'How Much Do I Have Lef Button Showing Me How Much I can Put in The Box.
×

Success!

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