www.webdeveloper.com
Results 1 to 2 of 2

Thread: using validatefields.js with two forms in one website

  1. #1
    Join Date
    Mar 2010
    Posts
    1

    using validatefields.js with two forms in one website

    I have two different forms on my site, both of which I would like to use the validatefields.js. It works fine on one form, but doesn't on the other and they have identical code. Do I need to name the forms differently? create a different validatefields.js file?

  2. #2
    Join Date
    Mar 2010
    Posts
    2,803
    You should be able to use the same .js file to validate both forms. If the id's of the input elements in both forms are exactly the same then you should be able to use the same functions in your .js file to validate both forms. The names of the forms is irrelevant if you use

    document.getElementById("id").value

    to get the input values from the form to validate.

    If the two forms are on the same web page then the form names, id's and element names should be different. If you are using something like document.forms[0]........ then the first form will be forms[0] and the second form will be forms[1] etc for mutiple forms on the one page.

    If you can, post your html form codes and the relevent functions from your .js file to help make your situation clearer.

Thread Information

Users Browsing this Thread

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

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