Newbie in Javascript
Hello all!
I am starting to use JS a couple of days now and mainly I am interested in using it in form validation and to create pop-ups.
I have 2 questions :
1) If a user doesn't have JS enabled, how will I check for empty fields in the form and show an alert box that prompts for corrections?
2) Also, I have seen sites that have the following : There is a link somewhere which works like this : [a] if you have JS enabled, it "recognizes" it and gives a pop-up window when clicked whereas [b] if you don't have JS enabled, it simply acts like a link and opens a new window (not a poup-up one).
Because I am a bit confused, I am staring to think that maybe JS causes more problems than it solves... Should a programmer use it or ,for instance, do a form validation in another page and don't count on the user having JS enabled?
dk01 posted this at 16:55 — 11th March 2006.
He has: 516 posts
Joined: Mar 2002
Generally the rule about JS validation is that it is poor. JS is a client side language and can be manipulated very easily. Although you can use JS to provide quick "validation", you should always use a server side language (PHP, ASP, ColdFusion) to validate a user's input after it has been submitted. For this reason unless you are going to require your users to have javascript enabled (like gmail, google maps, etc) you should stay clear of using it as your sole validation method.
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.