SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict
    Join Date
    Dec 2011
    Posts
    221
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Jquery validation and php form validation at once

    I'm a fan of the idea that validation should take place both server side and client side, but what if both execute at the same time? I'm using codeigniter and jquery validation. I've been coding almost three months, but the problem shows just now.

    Any help will do. thank you.

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,114
    Mentioned
    448 Post(s)
    Tagged
    8 Thread(s)
    The usual pattern is for JS to monitor user input and, via Ajax (checking the server-side validation rules), give feedback to the user without requiring a page refresh. Both shouldn't execute at the same time, as JS should do the checking on the client side when data is being typed, while server-side validation happens after submission.

    Having separate JS validation code is kind of inefficient, but still, JS will normally abort submission to the server if it catches an error.
    Facebook | Google+ | Twitter | Web Design Tips | Free Contact Form

    Forum Usage: Tips on posting code samples, images and more

    Forrest Gump: "IE is like a box of chocolates: you never know what you're gonna get."

  3. #3
    SitePoint Addict
    Join Date
    Dec 2011
    Posts
    221
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    It happens to me occasionally. Is it alright if I'll just do the server-side validation thing when js is turned off? But, honestly in my entire life I haven't seen a browser that its JS is turned off (except in ff webdeveloper) . I compromised to it halfheartedly.

  4. #4
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,114
    Mentioned
    448 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by claro View Post
    Is it alright if I'll just do the server-side validation thing when js is turned off?
    Indeed, there always should be a server-side fallback.

    I haven't seen a browser that its JS is turned off
    You wouldn't see it unless you were looking over the shoulders of all your site users. People have the option to turn off JS in their browser. But that's not the whole issue. They may be using a browser with poor JS support, or a browser plugin might be messing with your script etc. So JS can fail as well as be off. You just can't rely on it, because you can't control it.

    JS should be thought of as an enhancement rather than a dependancy—at least, as much as possible. So your server side script is essential, but client side validation is a nice enhancement for those who can access it or who want it.
    Facebook | Google+ | Twitter | Web Design Tips | Free Contact Form

    Forum Usage: Tips on posting code samples, images and more

    Forrest Gump: "IE is like a box of chocolates: you never know what you're gonna get."

  5. #5
    SitePoint Addict
    Join Date
    Dec 2011
    Posts
    221
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Thank you for enlightening me sir.

    So my problem about the server and client side validation
    showing at the same time is more on about my browser quirks?
    Is there anything I can do about it.

  6. #6
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,114
    Mentioned
    448 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by claro View Post
    So my problem about the server and client side validation
    showing at the same time is more on about my browser quirks?
    No, not all all. It's to do with your code setup. Perhaps explain what you have so far. (I'm not an expert at this, however, so if need be, we can encourage others to join the discussion.)
    Facebook | Google+ | Twitter | Web Design Tips | Free Contact Form

    Forum Usage: Tips on posting code samples, images and more

    Forrest Gump: "IE is like a box of chocolates: you never know what you're gonna get."


Tags for this Thread

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
  •