Results 1 to 8 of 8
  1. #1
    chizbox is offline Member
    Join Date
    Feb 2010
    Location
    Philippines
    Posts
    20
    Rep Power
    0

    Smile What is The Best Practice for Form Validation?

    Good Am! i just would like to ask from the experts what is the best html FORM validation practice that i can do with my application.

    is it advisable that i validate my forms on JavaScripts or i have to create classess for them?

  2. #2
    Join Date
    Jan 2009
    Posts
    14
    Rep Power
    0

    Default

    The jave script will be executed at client side without going to server for validation and it is faster which saves the user time. So with javascript you can have fast validation and users can correct immediately. If you have lot of fields and complex validation and if your javascript code increases there will be delay in form loading and response.

    If you have a validation with database tables then you must connect to database so at that time your validation can be java classes. The java classes validation will be executed at server side fastly and user form code will be reduced. If you have very complex validation of files also then only you should go for classes.


    So based on your requirement you can have javascript at client side prefarable.

  3. #3
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    Never assume that client side validations will work even if you have them.
    Always have server side validations. Client side validations are just to give users quick feedback.

  4. #4
    chizbox is offline Member
    Join Date
    Feb 2010
    Location
    Philippines
    Posts
    20
    Rep Power
    0

    Default

    @r035198x sir you mean that i should not use java scripts as my validation and rather use java classes to be safe? or you can have your java scripts then if not work it will be catched by the javal class validations? how can i do this?

  5. #5
    Aseem is offline Senior Member
    Join Date
    Mar 2009
    Location
    USA
    Posts
    127
    Rep Power
    0

    Default

    If it is form validation only, why not java script? even validation framework in struts uses javascript. But javascript provides you only form client side validation which is manily to check the users' input. For something like username cannot be less than 6 characters, there is no need to send data to the server and validate. It is just waste of time. Server side validation is usually done for authentication purposes. Both validations are important but if it is only form validation, why not JavaScript?

  6. #6
    chizbox is offline Member
    Join Date
    Feb 2010
    Location
    Philippines
    Posts
    20
    Rep Power
    0

    Default

    ic so can i expect that javascript validation will work on every client that will be using it? what about sir r035198x reply that js will not work all the time for every client

  7. #7
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    Read my reply again and don't confuse Javascripts with Java scripts. Java runs on the server. Javascript runs on the client browser.
    You must always have server side validations.
    You can have client side validations too to make the users' lives easier.
    Javascript can be turned off by users on their browsers meaning that your validations don't run. This will result in a very unfortunate situation for your data. Your data may also be manipulated through other clients (that are not browsers) and you can't guarantee that everyone who writes a client to use your data will always validate correctly.
    Always have server side validations.

  8. #8
    chizbox is offline Member
    Join Date
    Feb 2010
    Location
    Philippines
    Posts
    20
    Rep Power
    0

Similar Threads

  1. Replies: 0
    Last Post: 10-31-2009, 09:24 AM
  2. Java Form Validation
    By Lovie in forum Java Servlet
    Replies: 7
    Last Post: 09-22-2009, 05:52 PM
  3. Form Validation Design
    By Algatron in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 03-21-2009, 10:30 PM
  4. Form validation in struts
    By rekha in forum Web Frameworks
    Replies: 2
    Last Post: 03-19-2009, 08:55 AM
  5. form validation
    By abhiN in forum New To Java
    Replies: 0
    Last Post: 03-07-2008, 07:04 AM

Posting Permissions

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