SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Now available in Orange Tijmen's Avatar
    Join Date
    Jul 2004
    Location
    The Netherlands
    Posts
    1,469
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    AJAX - let javascript or PHP handle the validation?

    I'm working on a AJAX form, but I'm not so sure what would be the best way to handle the validation. I first though about just checking if the form fields are set with JavaScript, and then let PHP check if the name / email is really valid.

    But then i started to think, why not let JavaScript handle all of the validation and let PHP just process the data.

    So my question is, what would be the recommended way? Let either PHP or JavaScript do the full validation, or just check with JavaScript that the fields are set and do the full check with PHP. Or just let PHP handle everything?
    Travel Photos on Flickr - Twitter

    “Never give up. Never surrender”

  2. #2
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You should always have back-end validation. In case the user hasn't JavaScript enabled. As a bonus, you can also add front-end validation.

  3. #3
    Now available in Orange Tijmen's Avatar
    Join Date
    Jul 2004
    Location
    The Netherlands
    Posts
    1,469
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, that's true. Didn't think of what would happen is they don't have JavaScript enabled
    It's just that i recently came across several examples that only had JavaScript validation, and that made me wonder why they did that.
    Travel Photos on Flickr - Twitter

    “Never give up. Never surrender”


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •