Webmaster Forum


Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Coding Forum Problems with your code? Let's hear about it.

   

View Poll Results: Which type of validation would you suggest?
Javascript 1 4.35%
PHP 10 43.48%
Both 12 52.17%
Voters: 23. You may not vote on this poll

Reply
 
LinkBack Thread Tools Display Modes
Old 04-23-2006, 09:20 PM   #1 (permalink)
Contributing Member
 
ATLien's Avatar
 
Join Date: 10-13-03
Location: Atlanta, GA
Posts: 2,279
iTrader: 0 / 0%
ATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really nice
Send a message via AIM to ATLien
Javascript or PHP validation?

I am doing some form validation on my new site, and so far I have done php validation, but I was thinking of doing javascript to save the load time that comes with the php validation.

Do you think javascript form validation is enought, or would you suggest I do both just incase users disable javascript?
ATLien is offline  
Add Post to del.icio.us
Reply With Quote
Old 04-24-2006, 03:24 AM   #2 (permalink)
v7n Mentor
 
JamieJelly's Avatar
 
Join Date: 03-09-06
Location: London UK
Posts: 2,796
iTrader: 0 / 0%
JamieJelly is a web professional of the highest orderJamieJelly is a web professional of the highest orderJamieJelly is a web professional of the highest orderJamieJelly is a web professional of the highest orderJamieJelly is a web professional of the highest orderJamieJelly is a web professional of the highest orderJamieJelly is a web professional of the highest orderJamieJelly is a web professional of the highest orderJamieJelly is a web professional of the highest orderJamieJelly is a web professional of the highest orderJamieJelly is a web professional of the highest order
what kind of form fields are you validating?

You could use some DOM scripting and validate on the fly for fields such as valid telephone numbers, post (zip) codes, email addresses which would really be the most useful of javascript implementations, coupled with PHP validation for those with js disabled or unavailable.
JamieJelly is offline  
Add Post to del.icio.us
Reply With Quote
Old 04-24-2006, 06:53 AM   #3 (permalink)
Inactive
 
kyleposey's Avatar
 
Join Date: 03-02-06
Location: Indianapolis, Indiana
Posts: 142
iTrader: 0 / 0%
kyleposey is just really nicekyleposey is just really nicekyleposey is just really nicekyleposey is just really nicekyleposey is just really nicekyleposey is just really nicekyleposey is just really nicekyleposey is just really nicekyleposey is just really nicekyleposey is just really nicekyleposey is just really nice
Unless you are doing some really complex PHP coding, or doing some File I/O, there shouldn't be any load time difference.

However, not having any server-side validation will open you up to automatic bot submissions, and user errors for users that disable javascript.
kyleposey is offline  
Add Post to del.icio.us
Reply With Quote
Old 04-24-2006, 10:06 AM   #4 (permalink)
Contributing Member
 
ATLien's Avatar
 
Join Date: 10-13-03
Location: Atlanta, GA
Posts: 2,279
iTrader: 0 / 0%
ATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really nice
Send a message via AIM to ATLien
As of right now, I have a form with image verification for bot prevention, and php server side validation. I am going to add javascript verification to make the validation alittle more understandable for the non computer savy users.
ATLien is offline  
Add Post to del.icio.us
Reply With Quote
Old 04-24-2006, 11:35 AM   #5 (permalink)
Inactive
 
kyleposey's Avatar
 
Join Date: 03-02-06
Location: Indianapolis, Indiana
Posts: 142
iTrader: 0 / 0%
kyleposey is just really nicekyleposey is just really nicekyleposey is just really nicekyleposey is just really nicekyleposey is just really nicekyleposey is just really nicekyleposey is just really nicekyleposey is just really nicekyleposey is just really nicekyleposey is just really nicekyleposey is just really nice
Why not just display the error messages with PHP? Then the user can see the error messages and take them into consideration while they are filling out the form.
kyleposey is offline  
Add Post to del.icio.us
Reply With Quote
Old 04-24-2006, 12:01 PM   #6 (permalink)
Moderator
 
LazyJim's Avatar
 
Join Date: 10-13-03
Location: UK
Posts: 2,821
iTrader: 0 / 0%
Latest Blog:
None

LazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to all
Send a message via MSN to LazyJim
Post

I use JS but still have PHP backup

Need JS?
JS enables validation-as-you-type and other tricks with the potential to enhance the user experience. However you must be careful to ensure you only help and don't hinder!

Need PHP?
It depends how important the validation step is - as in what are the consequences of invalid or malicious data entry?
In most cases PHP validation will be required, you can incorporate this into any data processing steps you have in the PHP page if you think it will help speed it up.
Don't be tempted to use generic error messages, be as helpful as possible.

So in summary
In terms of power and flexibility, JavaScript has the best potential for helping users fill in forms (correctly). But PHP verification is usually required regardless
Remember any 'hacker' could POST any name=value data to any script, it's not limited to the form input elements and you can't rely on disabled/hidden input elements not being modified either.
__________________

-LJ-

My advice is to look at each case individually, with an informed mind and an appropriately balanced and objective viewpoint.

Web Design and Development, Ipswich, UK.
My deviantArt
LazyJim is offline  
Add Post to del.icio.us
Reply With Quote
Old 04-25-2006, 01:26 PM   #7 (permalink)
Inactive
 
veridicus's Avatar
 
Join Date: 01-18-06
Posts: 139
iTrader: 0 / 0%
veridicus is just really niceveridicus is just really niceveridicus is just really niceveridicus is just really niceveridicus is just really niceveridicus is just really niceveridicus is just really niceveridicus is just really niceveridicus is just really niceveridicus is just really niceveridicus is just really nice
You need to use PHP validation if you want to ensure good input data. It's the only way to properly validate.

You can use JS validation for usability. For example, you can check password length right after the user types it in for a quick message. But you still need to check the input in PHP because bots and others can easily bypass the JS.
veridicus is offline  
Add Post to del.icio.us
Reply With Quote
Old 04-26-2006, 06:40 AM   #8 (permalink)
Inactive
 
kyleposey's Avatar
 
Join Date: 03-02-06
Location: Indianapolis, Indiana
Posts: 142
iTrader: 0 / 0%
kyleposey is just really nicekyleposey is just really nicekyleposey is just really nicekyleposey is just really nicekyleposey is just really nicekyleposey is just really nicekyleposey is just really nicekyleposey is just really nicekyleposey is just really nicekyleposey is just really nicekyleposey is just really nice
(you guys forgot that he has image verification to thwart off bots...but good points nonetheless)
kyleposey is offline  
Add Post to del.icio.us
Reply With Quote
Old 04-26-2006, 09:56 AM   #9 (permalink)
Contributing Member
 
ATLien's Avatar
 
Join Date: 10-13-03
Location: Atlanta, GA
Posts: 2,279
iTrader: 0 / 0%
ATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really nice
Send a message via AIM to ATLien
I think I am just going to go full up with both php and javascript. I am also looking into some Ajax verification tools too. So we will see how it goes.
ATLien is offline  
Add Post to del.icio.us
Reply With Quote
Old 04-28-2006, 02:44 AM   #10 (permalink)
Contributing Member
 
MrMean's Avatar
 
Join Date: 07-03-04
Location: Devon, England
Posts: 313
iTrader: 0 / 0%
MrMean is just really niceMrMean is just really niceMrMean is just really niceMrMean is just really niceMrMean is just really niceMrMean is just really niceMrMean is just really niceMrMean is just really niceMrMean is just really niceMrMean is just really niceMrMean is just really nice
Send a message via MSN to MrMean Send a message via Yahoo to MrMean Send a message via Skype™ to MrMean
Although I should practice what I preech I would recommend using both. Several reasons for this.

The benifit of JS validation is its "on the page" therefore it does save the user pressing the dreaded back button and loosing what they've just typed out, in most cases anyway.

However using JS alone is a security risk to your website. You don't want people posting any & everything surely! It would be easy to flood submissions without PHP Authentication.
MrMean is offline  
Add Post to del.icio.us
Reply With Quote
Old 04-28-2006, 06:31 AM   #11 (permalink)
Inactive
 
kyleposey's Avatar
 
Join Date: 03-02-06
Location: Indianapolis, Indiana
Posts: 142
iTrader: 0 / 0%
kyleposey is just really nicekyleposey is just really nicekyleposey is just really nicekyleposey is just really nicekyleposey is just really nicekyleposey is just really nicekyleposey is just really nicekyleposey is just really nicekyleposey is just really nicekyleposey is just really nicekyleposey is just really nice
In an elegant PHP solution, the user never has to hit the back button, is displayed helpful error messages, and has the form pre-filled with the previously submitted values.
kyleposey is offline  
Add Post to del.icio.us
Reply With Quote
Old 04-28-2006, 01:23 PM   #12 (permalink)
Contributing Member
 
ATLien's Avatar
 
Join Date: 10-13-03
Location: Atlanta, GA
Posts: 2,279
iTrader: 0 / 0%
ATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really nice
Send a message via AIM to ATLien
That is how I do it. I list the errors on the form, with with the submitted data already filled in excluding the password, I unset that.
ATLien is offline  
Add Post to del.icio.us
Reply With Quote
Old 04-28-2006, 09:01 PM   #13 (permalink)
Lev
Inactive
 
Join Date: 04-21-06
Posts: 4
iTrader: 0 / 0%
Latest Blog:
None

Lev is liked by many
I think PHP validation is really best because some people have javascript disabled. If you are doing something fairly complex, then you can use both.
Lev is offline  
Add Post to del.icio.us
Reply With Quote
Old 05-20-2006, 10:02 PM   #14 (permalink)
Inactive
 
kenkam's Avatar
 
Join Date: 05-20-06
Posts: 40
iTrader: 0 / 0%
kenkam is a jewel in the roughkenkam is a jewel in the roughkenkam is a jewel in the roughkenkam is a jewel in the roughkenkam is a jewel in the roughkenkam is a jewel in the rough
I agree with LazyJim.

If you had JS on your site I could disable it on my browser and happily POST to your application.

JS is there to help the user. It is intended to give the client a richer interface. Some nice pointers to make it more user-friendly. You definately should not use it for validation if it is anything slightly more than trivial. PHP validations makes sure that it is probably done. There's no client-side validation that is secure. It is all server-side that does the best work in validation.

Summary - if the data more than trivial - use server side validation (PHP)
kenkam is offline  
Add Post to del.icio.us
Reply With Quote
Old 01-20-2007, 10:34 PM   #15 (permalink)
Contributing Member
 
explicitzone.com's Avatar
 
Join Date: 01-20-07
Posts: 125
iTrader: 0 / 0%
Latest Blog:
None

explicitzone.com is web crap
PHP
explicitzone.com is offline  
Add Post to del.icio.us
Reply With Quote
Old 01-22-2007, 01:44 PM   #16 (permalink)
Contributing Member
 
Izzmo's Avatar
 
Join Date: 11-01-03
Location: Kansas City
Posts: 1,097
iTrader: 0 / 0%
Latest Blog:
Happy New Year!

Izzmo is a splendid one to beholdIzzmo is a splendid one to beholdIzzmo is a splendid one to beholdIzzmo is a splendid one to beholdIzzmo is a splendid one to beholdIzzmo is a splendid one to beholdIzzmo is a splendid one to beholdIzzmo is a splendid one to beholdIzzmo is a splendid one to beholdIzzmo is a splendid one to beholdIzzmo is a splendid one to behold
Send a message via ICQ to Izzmo Send a message via AIM to Izzmo Send a message via MSN to Izzmo Send a message via Yahoo to Izzmo
Both, it is always good to be using both, just in case one doesn't work.

With most Ajax applications, if the user has disabled Javascript, then sometimes the PHP script will not work properly. That's the only problem I have, but then again, I just use them both whether the user has JS enabled or not.
__________________
Izzmo
Coding Guru Extraordinaire
ZeroWeb Hosting & Design - Customizable hosting for every type of user!
Izzmo is offline  
Add Post to del.icio.us
Reply With Quote
Old 01-22-2007, 01:52 PM   #17 (permalink)
Technical Support
 
Paul M's Avatar
 
Join Date: 12-14-05
Posts: 128
iTrader: 0 / 0%
Paul M is a glorious beacon of lightPaul M is a glorious beacon of lightPaul M is a glorious beacon of lightPaul M is a glorious beacon of lightPaul M is a glorious beacon of lightPaul M is a glorious beacon of lightPaul M is a glorious beacon of lightPaul M is a glorious beacon of lightPaul M is a glorious beacon of lightPaul M is a glorious beacon of lightPaul M is a glorious beacon of light
You must do php validation on the server side, whether you use JS as well on the clientside is personal choice. Relying on clientside validation only would be asking for serious trouble.
Paul M is offline  
Add Post to del.icio.us
Reply With Quote
Old 01-24-2007, 12:53 PM   #18 (permalink)
Contributing Member
 
Izzmo's Avatar
 
Join Date: 11-01-03
Location: Kansas City
Posts: 1,097
iTrader: 0 / 0%
Latest Blog:
Happy New Year!

Izzmo is a splendid one to beholdIzzmo is a splendid one to beholdIzzmo is a splendid one to beholdIzzmo is a splendid one to beholdIzzmo is a splendid one to beholdIzzmo is a splendid one to beholdIzzmo is a splendid one to beholdIzzmo is a splendid one to beholdIzzmo is a splendid one to beholdIzzmo is a splendid one to beholdIzzmo is a splendid one to behold
Send a message via ICQ to Izzmo Send a message via AIM to Izzmo Send a message via MSN to Izzmo Send a message via Yahoo to Izzmo
Ahh.. you make some good points Paul

w00t - You are over 100 posts (finally)
__________________
Izzmo
Coding Guru Extraordinaire
ZeroWeb Hosting & Design - Customizable hosting for every type of user!
Izzmo is offline  
Add Post to del.icio.us
Reply With Quote
Old 01-24-2007, 05:11 PM   #19 (permalink)
Inactive
 
Join Date: 02-15-06
Posts: 86
iTrader: 0 / 0%
gastongr is liked by many
JavaScript is good to speed up the process but it should always be backed with server side validation as it's easy to bypass.
gastongr is offline  
Add Post to del.icio.us
Reply With Quote
Old 01-24-2007, 05:41 PM   #20 (permalink)
Inactive
 
Join Date: 01-23-07
Location: Netherworld, under Buenos Aires.
Posts: 169
iTrader: 0 / 0%