/    Sign up×
Community /Pin to ProfileBookmark

if statement with textbox

Hi guys,

I’m trying to create a textbox that uses an if statement.
If the words vgn, vgx,vgc,pcv,pcg are typed into the textbox it will input a “-” in front of those letters in the textbox , “else” it will input nothing.
i.e:
Input: vgn
Output: vgn-

can someone help me on this?

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@MikeOSSep 09.2010 — <form id="form1">

<input type="text" id="txtInput" size="30" onblur="checkValue()" />

</form>

<script type="text/JavaScript">

function checkValue()

{

var txtCtrl = document.getElementById("txtInput");

var txtValue = txtCtrl.value;

if (txtValue == "vgn" || txtValue == "vgx" || txtValue == "vgc" || txtValue == "pcv" || txtValue == "pcg")

{

txtCtrl.value = txtValue + "-";

}

}

</script>

This is probably the simplest way to do it, ordinarily I wouldn't use events like this but I've done it this way for simplicity sake.
Copy linkTweet thisAlerts:
@fallencmdauthorSep 12.2010 — Thanks MikeOS that really did it, i just had to change the event to onkeypress.

?
Copy linkTweet thisAlerts:
@CompEngineer10Sep 20.2010 — Hello I need some help using visual studio/ visual c++ 2008

I have to make a textbox and the user enters the amount of money they want to bet but I have to check if that value is between 2 and 250. Any help would be great.
Copy linkTweet thisAlerts:
@BerniAug 16.2011 — Hello I need some help using visual studio/ visual c++ 2008

I have to make a textbox and the user enters the amount of money they want to bet but I have to check if that value is between 2 and 250. Any help would be great.[/QUOTE]


Hi, you can find it at dreamincode.net. There is a tutorial assumes that you have little-to-no knowledge of the C++ Programming. Good luck ?
×

Success!

Help @fallencmd 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.4,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...