/    Sign up×
Community /Pin to ProfileBookmark

input box validation

I have a shopping cart application that can have anywhere from 20 to 250 input boxes on the screen at one time. If a user puts in quanties for the items, and clicks on another link on the page, the page does not indicate that the user has left quantities in the input boxes. I want to change that. If the user does not click on add to cart, and clicks somewhere else, I want a javascript that looks to see if there are numbers in the boxes, and issues an alert that asks if they would like to continue with their request, and cancel to add to cart. I am awful at javascript, so I would appreciate any kind of script that I could modify slighty to accomplish this task.

thank you

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@vwphillipsOct 19.2004 — a starter for the verification

if you need assistane in customising the Warning panel or adding the functions to the buttons let me know


[code=php]

<html>

<head>
<title></title>
<script language="JavaScript" type="text/javascript">
<!--

function TBCheck(){
TBNu=document.getElementsByTagName('input');
for (i=0;i<TBNu.length;i++){
if (TBNu[i].value==''){
document.getElementById('Warning').style.visibility='visible';
return;
}
}
}

//-->
</script>
</head>

<body>

<div id=Warning style="position:absolute;visibility:hidden;left:300px;top:100px;width:200px;height:100px;border:solid black 1px;background-color:yellow;text-align:center;" >
Inputs are not complete<br>
<input type="button" name="" value="Continue" onclick="javascript:document.getElementById('Warning').style.visibility='hidden';" >
<input type="button" name="" value="Cancel" onclick="javascript:document.getElementById('Warning').style.visibility='hidden';">
</div>

<input name="" size="10"><br>
<input name="" size="10"><br>
<input name="" size="10"><br>
<input name="" size="10"><br>
<input name="" size="10"><br>
<input name="" size="10"><br>
<input name="" size="10"><br>
<input name="" size="10"><br>
<input name="" size="10"><br>
<input type="button" name="Check" value="Check Text Boxes" onclick="javascript:TBCheck();" >
</body>

</html>

[/code]


remove any spaces between java & script this site may add
×

Success!

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