dcsimg
www.webdeveloper.com
Results 1 to 8 of 8

Thread: Form Validation in Table

  1. #1
    Join Date
    Jul 2010
    Posts
    3

    Form Validation in Table

    Hello everyone! I'm new to these forms and (very new to) JS. I hope someone can help.

    What I am trying to do is have a form in a table validate in the same order as the tab order. The form is in a table with three columns. There are a few fields in each column below each other. They are not in separate cells. (Spacing issues when they are in their own cells.) Validation is working correctly, however when it is validating, it validates column by column, not by "row."

    Can anyone help me get it to validate in the correct order?

    Here is the JavaScript form validator

    and here is the form with the calls to the script to validate:

  2. #2
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,672
    forms are usually validated using a loop which does some tests to the given form elements. usually such loops go through the form elements according to their indexes and no matter what html is used for visual positioning of these elements. making such loop to go through the form elements in another order may slower the script and i doubt this is a very good idea

  3. #3
    Join Date
    Jul 2010
    Posts
    3
    So... How should I do it?

  4. #4
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,672
    Quote Originally Posted by macboy16 View Post
    So... How should I do it?
    1. you create an array which elements are the given form elements (names or ids) ordering them as required

    2. then you validate them using a loop which will go not through the standart form elements collection as by default but through this array

    there may be several ways of doing this i suppose

  5. #5
    Join Date
    Jul 2010
    Posts
    3
    How do I do that? I'm sorry, I don't know how to do anything in JS.

  6. #6
    Join Date
    Jan 2009
    Location
    127.0.0.1
    Posts
    126
    do you know any other scripting code or 'programming' code ie C, C#, C++, PHP, Java? if not you will have to learn javascript before you can write it. If you do know one of the others, many of the statements are the same it is just learning a little new syntax and implementing it correctly. that's basically what i did; i knew some C++ and just used my knowledge of that to learn javascript fairly quickly.

    to learn javascript start here.

    they even have the basis for a form validation there but it is not that great IMO. i found another one using google and slightly modified it to make it work how i wanted to.

    and if you are going to be validating forms i imagine you are going to be submitting them to an email address or a data base in which case you should also learn php. PHP can also validate the form for you but it does it server side so it takes longer but is still a solid way to do so.

  7. #7
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,672
    Quote Originally Posted by spotted zebra View Post
    ... PHP can also validate the form for you but it does it server side so it takes longer but is still a solid way to do so.
    and one should use server-side validation no matter was the form validated with JS or not to prevent sql-injections or another malicious data because js-validation is not safe

  8. #8
    Join Date
    Jan 2009
    Location
    127.0.0.1
    Posts
    126
    yes i haven't progressed that far in my self teaching so i do not know all of the stipulations and uses of it yet. glad to know you can stop stuff like that though.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles