Im trying to make a "coupon" form. So that when my users go to the text field and type in 'hello' persay it then in turn will open the form that corresponds to the code. I am going to make various words/codes to use for the coupon. I'd like to make it so that there is no way they can bypass this, and that they can not see this javascript if they click the view source file. Can someone help me. It seems simple I believe, though I do not know anything about javascript. so //comments would be perferred so that I understand each command and statement happening for further use.Thanks ahead of time.
Asked
Active
Viewed 139 times
-1
-
Are you planning to use a library like jQuery? Put up your HTML code and it will make it easier for people to help you. And it's `per se` :) – Nick Jul 30 '12 at 11:32
-
Welcome to SO. Please read the FAQ. This is a very general question; it sounds like you first need to do some research. If you run into problems and then have specific questions, come back (but post some code!) and we can help. – Mitya Jul 30 '12 at 11:32
-
"I do not know anything about javascript" --- so grab some book and learn. That is how it happens. No one borns with js knowledge – zerkms Jul 30 '12 at 11:34
-
Let's not just heap on the -1 votes, people. – Nick Jul 30 '12 at 11:35
-
@Nick: question with "I don't know it so please do it for me and comment so I could copy-paste without understanding" is a perfect candidate to be closed (and downvoted) – zerkms Jul 30 '12 at 11:36
-
@zerkms Sure, I get your rationale. But it's the guy's first question. And as Goethe said, "Correction achieves much, but encouragement achieves more." (Or sommat like that.) – Nick Jul 30 '12 at 11:38
-
@Nick: downvoted and closed question != banned account. It is a thing to think about. My several questions were closed on another stackexchange sites because of lack of my research and it was my fault. I don't treat them as an end of the world, but as a (free!!) lesson to me. – zerkms Jul 30 '12 at 11:45
-
Im not trying to steal a code, Ive been trying to do this all night long. been up for 20 hours right now working on codes, this is my last for the day. all i want to is-- SHOW that would be the variable input of the coupon. HIDE>>>>Hiding the Javascript I cant do, thats ok, but is it possible to encrypt the codes? Im just getting back up on everything i have been off computer for few months now. Sorry to be a newb– nextlevelgamingCO Jul 30 '12 at 11:48
1 Answers
2
You can't hide javascript because the javascript has to be accessible for the browser to execute it. And if it is accessible to the browser then it is possible for anyone to access it manually through the URL.
If you don't want users to see the code that handles coupon values, you need to do it in the server-side, not in javascript.
You can use javascript to make an ajax call that sends to the server the coupon value entered. The server side can use this value to choose and return the HTML that corresponds to the coupon value. But the code that checks the coupon value has to be in the server-side if you want it to be hidden.

kgautron
- 7,915
- 9
- 39
- 60
-
Only problem is I'm using a website that does not allow server side anything. Its a forum site. Something simple. And like I said above, is it possible to encrypt all the coupon codes? – nextlevelgamingCO Jul 30 '12 at 11:50
-
Server-side means the code executed on the server, and as a consequence not accessible by users. PHP is server-side code for example. A forum necessarily has a server-side to store the posts, users, build the pages etc... You can encrypt but it will not help, anything purely in javascript will never be secure because it is not hidden and can be modified. – kgautron Jul 30 '12 at 11:54
-
So say like i did say ha, i can not upload any files or create any files of php, ajax, or whatever. So what would you suggest be my best option? – nextlevelgamingCO Jul 30 '12 at 12:39
-
How do you expect to achieve anything without creating/uploading files? – kgautron Jul 30 '12 at 14:00