SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Jan 2010
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP validation better then java script ?

    Hi,
    I use PHP validation for my sites it is better then java script validation ?

  2. #2
    SitePoint Zealot
    Join Date
    Aug 2009
    Posts
    150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it's not better, since you shouldn't really compare between them. JavaScript validation should be for user convenience to reduce user waiting times. However, you should never relay purely on JS validation, since it can be disable or modified. So server validation is always required even if you have JS validation.

  3. #3
    SitePoint Member
    Join Date
    Jan 2010
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi igv

    How are you? I would like to thanks for give your comment.

    Thanks

  4. #4
    SitePoint Zealot
    Join Date
    Aug 2009
    Posts
    150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no problem, hope you'll find it useful for you.

    Welcome to SitePoint by the way

  5. #5
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,600
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by Alamaramin View Post
    Hi,
    I use PHP validation for my sites it is better then java script validation ?
    Neither is better since they serve two entirely different purposes.

    PHP validation is your validation. It ensures that the information you receive is what you expect to receive and rejects anything that isn't correct. Without it there is nothing to stop you from receiving JUNK.

    JavaScript validation is for your visitor. It provides those with JavaScript enabled with more immediate feedback as they are filling out the form. Without it your visitor has to wait until after they submit the form to find out if they entered it correctly.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  6. #6
    SitePoint Wizard
    Join Date
    Jul 2003
    Location
    Kent
    Posts
    1,921
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Use both.
    Javascript to spot errors before the user submits (avoids having to re-enter data), and PHP to catch those with JS disabled or trying something unusual or sneaky.

    Two barriers are better than one.


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
  •