/    Sign up×
Community /Pin to ProfileBookmark

what’s wrong with this?

[CODE]
function FormValidation() {
if (!check_exceptions()) {
alert(exception_msg);
return false;
}
var value = product_option_value(“men_size”);
var value2 = product_option_value(“colour_001”);
var val1 = value.toLowerCase().indexOf(“select”);
var val2 = value2.toLowerCase().indexOf(“select”);
if ((val1 > -1) && (val2 > -1)){
alert (“please choose a size and colour”);
return false;
}
elseif (val1 > -1){
alert (“please choose a size”);
return false;
}
elseif (val2 > -1){
alert (“please choose a colour”);
return false;
}
if(document.getElementById(‘product_avail’))
if(document.getElementById(‘product_avail’).value == 0) {
alert(“Out of stock”);
return false;
}

return true;
}
[/CODE]

an online validator keeps giving me this as a report:

[QUOTE]

Error:
Implied global: alert, check_exceptions, elseif, exception_msg, product_option_value

Problem at line 14 character 19: Missing semicolon.

elseif (val1 > -1){

Problem at line 15 character 1: Expected to see a statement and instead saw a block.

alert (“please choose a size”);

Problem at line 15 character 1: Stopping, unable to continue. (48% scanned).

[/QUOTE]

I’ve put a semicolon anywhere and everywhere.. ??

_mu_

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@NatdripAug 08.2007 — [CODE]
if(document.getElementById('product_avail'))
if(document.getElementById('product_avail').value == 0) {
alert("Out of stock");
return false;
}

[/CODE]

to this
[CODE]
if(document.getElementById('product_avail'))[COLOR="DarkRed"]{[/COLOR]
if(document.getElementById('product_avail').value == 0) {
alert("Out of stock");
return false;
[COLOR="DarkRed"]}[/COLOR]
}
[/CODE]
Copy linkTweet thisAlerts:
@k1loAug 09.2007 — Try to replace 'elseif' with 'else if'
×

Success!

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