JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old August 21st, 2003, 09:01 AM
bashy bashy is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 2 bashy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Script for "Agreements" before Adding Item to cart

hi everyone i'm just starting a site and learning as i go along, been looking for a way to setup my site so when a customer try's to add an item to the cart there is call to a script (java would be the easy way) to make sure the checkbox is checked then passing it to the cart, if not a alert would ask user to click the checkbox agreement. Wondering how one would go about doing this!

This question has come up many times before and has several answers to going about it. But I've missed all of them.


The idea is that if the order gets through, then it's evident that the customer clicked "I Agree", otherwise the verification routine would've seen that the customer did not click and halted the passing of the form results.

there a chance anyone could post the actual idea's (the javascripts +code) that others have posted!? i searched but could not get anything.

Reply With Quote
  #2  
Old August 21st, 2003, 10:31 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
You should never use javascript to validate data that matters. Javascript can be disabled by the user. Validate this server side by checking to make sure a value has been passed for the checkbox field. If not, reprint the order form with an error message noting that the agreement box must be checked. Also, you should make sure you always retrieve prices for products from the database rather than from hidden fields. Imagine I viewed your cart page, downloaded the source, changed price values, and submitted from my local system. I could get a heck of a deal on your products if you're not validating my input server-side. You may already be doing that, but I thought I'd drop a tip just in case.

Reply With Quote
  #3  
Old August 21st, 2003, 06:25 PM
bashy bashy is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 2 bashy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I could not agree even more about not using java. THe reason I have been looking at java is due to the fact that my skills just dont go that far. I'm wondering if there is a price to which you would be willing to agree upon on setting up a little server side script/code to work out this validating process for me! I understand I can never ask anything for free for such things so i have to be fair, if you feel you have time and need to take on a quick hobby for little money please let me know. Thanks


Quote:
Originally posted by dhouston
You should never use javascript to validate data that matters. Javascript can be disabled by the user. Validate this server side by checking to make sure a value has been passed for the checkbox field. If not, reprint the order form with an error message noting that the agreement box must be checked. Also, you should make sure you always retrieve prices for products from the database rather than from hidden fields. Imagine I viewed your cart page, downloaded the source, changed price values, and submitted from my local system. I could get a heck of a deal on your products if you're not validating my input server-side. You may already be doing that, but I thought I'd drop a tip just in case.

Reply With Quote
  #4  
Old August 22nd, 2003, 08:25 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
I'm afraid I'm not really in a position right now to take on any more work, though I appreciate your desire to compensate. Maybe somebody else'll pick this up and run with it. What code are you using for your cart? Have you checked into other cart programs that might be more flexible or easier to modify?

Reply With Quote
  #5  
Old August 23rd, 2003, 11:21 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
Send a message via ICQ to stumpy Send a message via MSN to stumpy
bashy - you seem to be using the terms Java & Javascript as though they are the same thing. Please understand that Javascript and Java are two completely different things. Java is an OO programming language, which can be used to create applications, just like C++, etc. JavaScript, on the other hand is simply a scripting language which is used to perform basic actions in a user's broswer (i.e. the client side).

As dhouston pointed out, you should use your server-side language (e.g. PHP, ASP, ASP.NET) to perform the validation on the users acceptance of the Terms.

Reply With Quote
  #6  
Old September 6th, 2003, 08:14 PM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 788 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 7
Quote:
You should never use javascript to validate data that matters
I'm not sure I agree 100% with this. This statement begs the question, "why validate data that doesn't matter?".

Aside from that, I think Javascript should be used to validate data as well as the server. This is not redundant in my mind as the server will most likely never have to do validation if Javascript is doing it. I wouldn't even bet on the server having to do this work even 1% of the time. Further, you would be saving yourself or your company precious server time/hardware by preserving those ticks of the server. Personally, I'd rather waste server hits on accepting credit cards through costly SSL requests than waste them on validating data that could have been handled by the user's client machine. Especially today with all these folks purchasing hardware that is way beyond the scope of what they will ever use that hardware for. You may as well help them get their money's worth.

Also, How many people do you know surfing the net with Javascript off? First of all, it is very unproductive to have javascript off in your browser. Secondly, how many people even know how to turn it off. I would conduct a survey, however, I feel that the results would be fixed. I'm almost certain that most would go hunting for this feature before answering the poll for fear that they would look quite silly not knowing how to find this feature.

Ok, now that I'm done with this quick rant, I'll close by saying doens't be so sceptical about user not having javascript on.

Even in cases where javascript was off, you could just use the <noscript></noscript> tags to redirect those few with javascript off.
__________________
__________________________________________________ _
Wil Moore III, MCP | Integrations Specialist | Senior Consultant
Are You Listed...? | DigitallySmooth Inc.

Reply With Quote
  #7  
Old September 8th, 2003, 08:02 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
I agree fully, laidbak. I should have said "You should never rely on javascript alone to validate data that matters." Javascript validation is a good thing, but you wouldn't want to rely on it alone in a case like the one given here. It's a way of preventing needless connections to the server, as you point out. Regarding having js turned off, I wasn't proposing that a great many people surf with js disabled. But if I wished to try maliciously to bypass somebody's sign-up agreement or other validation in a form, the first thing I'd do would be to turn off javascript in my browser in hopes that the programmer was using js only.

Reply With Quote
  #8  
Old September 8th, 2003, 12:23 PM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 788 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 7
Quote:
But if I wished to try maliciously to bypass somebody's sign-up agreement or other validation in a form, the first thing I'd do would be to turn off javascript in my browser in hopes that the programmer was using js only.

Now it is I who must agree with you as the above is a great point to note for many novice developers.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > Script for "Agreements" before Adding Item to cart


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT