/    Sign up×
Community /Pin to ProfileBookmark

validating form

hi
i have this order form and i’m validating the required fields by this tags
<input type=’hidden’ name=”required” value=”name,city,pobox,zip,mobile,tele,email”/>
[B]1st Q:[/B] is it possible to use [B]OR[/B] between two inputs i.e if the user enter A or B the form should be valid otherwise it will redirect him to the error page. i.e <input type=’hidden’ name=”required” value=”name,city,pobox,zip,[COLOR=Red]mobile or tele[/COLOR] email”/>

[B]2nd Q,[/B] we are selling CDs on this website and we have two types of CDs, only CD and with giftbox CD (both of them checkboxes)
and under each type quantity from 1-10(dropdown menu)
and more than 10 (textfield)
so total of 4 quantities.
what i want is to check if the user selected either one of the CDs , either of the quantites

i tried this code but it’s not working

<script language=”javascript”>
function verify(){
var msg = ” you are required to complete the following fields: “;

if (document.orders.only_cd.checked==false && document.orders.giftbox.checked==false)
{msg = msg + ” – CD type”;

}

if(document.orders.quantity_only_cd.value==”quantity” && document.orders.quantity_cd_giftbox==”quantity”)
{
msg = msg + ” – CD quantity”;
}

else {
alert(msg);
return false;
}

}
</script>

and i called the function on the <input type=”submit” name=”Submit” value=”Submit” onclick=”verify();”/>

what’s wrong with the code?

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@forty2Oct 10.2006 — Don't do form validation with Java Script, user every time can turn of java script and your validation.Write server side script for this validation and call with AJAX.
Copy linkTweet thisAlerts:
@widd_gamaauthorOct 10.2006 — what about the <input type='hidden' name="required" value="name,city,pobox,zip,mobile or tele, email"/>

can i put OR??
Copy linkTweet thisAlerts:
@widd_gamaauthorOct 11.2006 — it's very urgent plz
Copy linkTweet thisAlerts:
@CharlesOct 11.2006 — 1) Get the page to pass [url="http://validator.w3.org/]The Validator[/url].

2) Then, and only then, post the URL.
×

Success!

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