Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 8 of 8
  1. #1
    Senior Member kade119's Avatar
    Join Date
    Feb 2007
    Location
    USA
    Posts
    532
    Member #
    14888
    Liked
    1 times
    is there a form validator you guys prefer over the others?

  2.  

  3. #2
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Well, it's usually a bad idea to rely on Javascript for form validation, as anyone can just disable Javascript and bypass it. Validation is best done on the server. That said, on the very rare occasion that I write a form validator of some sort in JS, I just hand-roll it using one of the frameworks that are out there. It's typically fairly straightforward to do.

  4. #3
    Senior Member hyperair's Avatar
    Join Date
    May 2005
    Posts
    452
    Member #
    9892
    While I agree with what Shadowfiend said about form validation best done on the server, I believe that the best approach would to have both. That way the form validation could be handled without having to repeatedly submit the page, as well as having a fallback if the Javascript version doesn't work. Basically the Javascript version for the user's convenience, and the server-side checking to make sure bad data doesn't get through anyway.

    That said, I usually do my validation functions based on the form itself. No centralized algorithm, though I might try to do that if all the forms I have on a particular site are very similar. Perhaps you could show us the form you have and we can see what would suit it best.
    Hyperair

  5. #4
    Senior Member Steax's Avatar
    Join Date
    Dec 2006
    Location
    Bandung, Indonesia
    Posts
    1,207
    Member #
    14572
    Since I use jQuery, I use the form plugin to do this in JS, then server-side in PHP to check the data before they are actually processed.
    Note on code: If I give code, please note that it is simply sample code to demonstrate an effect. It is not meant to be used as-is; that is the programmer's job. I am not responsible to give you support or be held liable for anything that happens when using my code.

  6. #5
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    To be honest, doing both in the sense of implementing the checks on both client and server is needless repetition. Especially since you're already using Javascript, the best way is probably to mix some saucy AJAX in that'll let you validate things on the server with the same code that you will validate them on actual submission. That way, you can have the code in one place and use it from both client and server. Sure, it'll still require a round-trip to the server, but if it's well-built, that won't matter that much.

  7. #6
    Senior Member kade119's Avatar
    Join Date
    Feb 2007
    Location
    USA
    Posts
    532
    Member #
    14888
    Liked
    1 times
    okay.... first i guess my question should be.. whats a good php form validator source ?

    2nd.. what does jQuery actually do?

  8. #7
    Senior Member hyperair's Avatar
    Join Date
    May 2005
    Posts
    452
    Member #
    9892
    Ah. AJAX eh? Totally forgot about that for a while =P Agreed.
    Hyperair

  9. #8
    Senior Member Steax's Avatar
    Join Date
    Dec 2006
    Location
    Bandung, Indonesia
    Posts
    1,207
    Member #
    14572
    Well my inline functions do a lot of stuff, and many are with AJAX - username availability, password strength, etc. The rest are just string/date/number validators, simple JS stuff. So I really don't think it's too much of a job, is it?

    jQuery is a JS library, not unlike prototype, mootools, or YUI. It's aimed at manipulating elements directly (very conveniently done with CSS-style selectors, so you can manipulate sets at once). If you haven't tried it, I suggest you take a look at their site.
    Note on code: If I give code, please note that it is simply sample code to demonstrate an effect. It is not meant to be used as-is; that is the programmer's job. I am not responsible to give you support or be held liable for anything that happens when using my code.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 01:00 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com