Home

Forums

Web development

 

 

 

 
     
 
dna88 Web development and Technology Forum
 
Profile   Register   Memberlist   Usergroups   FAQ   Search  Log in
JavaScript Form Validation - Help

 
Post new topic   Reply to topic    dna88 Forum Index -> Web scripting language Discussion Forum
Author Message
emilebos
Just In
Just In


Joined: 06 Oct 2004
Posts: 2

Post Post subject: JavaScript Form Validation - Help Reply with quote

A question if anyone can help.

I am trying to find someone to code a JavaScript form validation script where the validation is only required if a certain value is input into a related field.

Eg. if on an order page no quantity is input for a particular product then there is no need to validate the size for that product. So the form validation is only called when there is a quantity greater than zero input for each product ordered.

The form in question can be found here..

[http://www.cheekypossum.com/lollipop_test_mode_v2.htm]

If anyone can help I would be more than happy to pay for the time & expertise.
_________________
Emile Bos
Wed Oct 06, 04 4:27 am
Back to top
emilebos View user's profile Send private message Send e-mail MSN Messenger
quantum
Site Admin
Site Admin


Joined: 07 Mar 2004
Posts: 1048
Location: Dhaka, Bangladesh

Post Post subject: Reply with quote

Hi emilebos,

Welcome to the QC forum.

Now, make a few things clear for me. As it is, there is no validation used whatesoever on that page. I don't see anything on the page that is validating the size of the product chosen. All that the script is doing is it is taking each input and select fields(without any varification), passing them to the CC processing page.

What it is not doing is, it is not checking to see if the client entered at least 1 product. That is something you may want to validate. Could you please explain what you mean by "Validating the size of product"? What kind of validation you are talking about here?
_________________

Dust fills my eyes / Clouds roll by / and I roll with them / Centuries cry / Orders fly / and I fall again
Afford best design, implement best solution. Outsource your web design.
Wed Oct 06, 04 6:19 am
Back to top
quantum View user's profile Send private message Visit poster's website AIM Address
emilebos
Just In
Just In


Joined: 06 Oct 2004
Posts: 2

Post Post subject: Reply with quote

what I need is for the form to check each product qty where there is a size field included and require the form to indicate to the user that a size must be selected if the qty ordered is greater than zero.
_________________
Emile Bos
Wed Oct 06, 04 6:29 am
Back to top
emilebos View user's profile Send private message Send e-mail MSN Messenger
quantum
Site Admin
Site Admin


Joined: 07 Mar 2004
Posts: 1048
Location: Dhaka, Bangladesh

Post Post subject: Reply with quote

Nice. That makes things clear for me. I can write a small script for you on that. Give me a few hours. Gentle smile
_________________

Dust fills my eyes / Clouds roll by / and I roll with them / Centuries cry / Orders fly / and I fall again
Afford best design, implement best solution. Outsource your web design.
Wed Oct 06, 04 7:05 am
Back to top
quantum View user's profile Send private message Visit poster's website AIM Address
hasnut
Expert User
Expert User


Joined: 28 Aug 2004
Posts: 201

Post Post subject: Reply with quote

Emilebos. whats your time zone?
_________________
Sarder Hasnut
MCSD, CIW A

Need Low Cost Prefessional Hosting Contact me
Wed Oct 06, 04 11:05 am
Back to top
hasnut View user's profile Send private message Visit poster's website MSN Messenger
quantum
Site Admin
Site Admin


Joined: 07 Mar 2004
Posts: 1048
Location: Dhaka, Bangladesh

Post Post subject: Javascript validation solution Reply with quote

Alright, here it is. Pretty straight forward and it does what you want to do for that page. It will check if any of the product has more than 0 as quantity and if so it will check if the product size has been selected. If not, it will give an error message. If the user selects a product size it will redirect to the CC page.

Enter this code below, in the header section of your page. Right after the meta tag will do.

Code:
<script language="JavaScript1.2">

function checksize(){
var n1 = document.form1.Multi_Dress_qty.value;
var n2 = document.form1.Multi_Top_qty.value;
var n3 = document.form1.Multi_Skirt_qty.value;
var n4 = document.form1.Rainbow_Dress_qty.value;
var n5 = document.form1.Rainbow_Pants_qty.value;
var n6 = document.form1.Rainbow_Top_qty.value;
var n7 = document.form1.Rainbow_Skirt_qty.value;
var n8 = document.form1.Multi_Hat_qty.value;
var n9 = document.form1.Multi_Bag_qty.value;


var s1 = document.form1.Multi_Dress_size.selectedIndex;
var s2 = document.form1.Multi_Top_size.selectedIndex;
var s3 = document.form1.Multi_Skirt_size.selectedIndex;
var s4 = document.form1.Rainbow_Dress_size.selectedIndex;
var s5 = document.form1.Rainbow_Pants_size.selectedIndex;
var s6 = document.form1.Rainbow_Top_size.selectedIndex;
var s7 = document.form1.Rainbow_Skirt_size.selectedIndex;
var s8 = document.form1.Multi_Hat_size.selectedIndex;


if (n1 == 0 && n2 == 0 && n3 == 0 && n4 == 0 && n5 == 0 && n6 == 0 && n7 == 0 && n8 == 0 && n9 == 0)
testresult=true
else{
if ((n1>0 && s1 == 0) || (n2>0 && s2 == 0) || (n3>0 && s3 == 0) || (n4>0 && s4 == 0)
|| (n5>0 && s5 == 0) || (n6>0 && s6 == 0) || (n7>0 && s7 == 0) || (n8>0 && s8 == 0))

{
alert("Please select a size for your chosen product.")
testresult=false
}
else
testresult=true
}

return (testresult)
}

function checkban(){
if (document.layers||document.all||document.getElementById)
return checksize()
else
return true
}
</script>


Find out this code in your current page:
Code:
<FORM NAME=form1 METHOD=POST ACTION="https://vault.safepay.com.au/cgi-bin/test_payment.pl">


Replace with:
Code:
<FORM NAME=form1 METHOD=POST form1 onSubmit="return checkban()" ACTION="https://vault.safepay.com.au/cgi-bin/test_payment.pl">


Let me know if there is any problem.
_________________

Dust fills my eyes / Clouds roll by / and I roll with them / Centuries cry / Orders fly / and I fall again
Afford best design, implement best solution. Outsource your web design.
Wed Oct 06, 04 11:35 am
Back to top
quantum View user's profile Send private message Visit poster's website AIM Address
Display posts from previous:   
Post new topic   Reply to topic    dna88 Forum Index -> Web scripting language Discussion Forum All times are GMT - 7 Hours
Page 1 of 1

 

Partners and Resources

Bangladesh hosting company

Bangladesh web design

Driven by phpBB © phpBB Group