|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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. |
|
#2
|
||||
|
||||
|
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.
|
|
#3
|
|||
|
|||
|
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. ThanksQuote:
|
|
#4
|
||||
|
||||
|
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?
|
|
#5
|
||||
|
||||
|
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. |
|
#6
|
|||
|
|||
|
Quote:
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. |
|
#7
|
||||
|
||||
|
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.
|
|
#8
|
|||
|
|||
|
Quote:
Now it is I who must agree with you as the above is a great point to note for many novice developers. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > JavaScript Development > Script for "Agreements" before Adding Item to cart |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|