• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Multiple form values validation

 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello!

I have multiples form values with a single name. The user has to type a password twice to confirm that they haven't made a mistake.

The HTML code:

I need to validate that the two passwords are filled correctly (not empty) before sending them to the server.

I'm doing like this, with JS, but it doesn't work!

Please, help me.
Thanks!
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

var pw1 = form.password[0].value;//Why doesn't it work??


Why would you think that this would work? Just naming multiple elements with the same name doesn't create any type of array of elements.

If you want to address them distinctly, assign unique id values to each element.
[ January 10, 2008: Message edited by: Bear Bibeault ]
 
Enrique Villamizar
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Why would you think that this would work? Just naming multiple elements with the same name doesn't create any type of array of elements.


Well, To be honest, I do that way when processing information at the server side in PHP and it works. That is why I think that it also could work in JS. If you send the form using the GET method you can see the array in the URL.
But the question could be: Is it possible to do something like that in javascript?

I need to validate multiples form values using a single name...maybe the way lists work, or...I don't know. The choice of using different names is hard to do it because I have to change the code in the dinamic server scripts.

Thank you for your cooperation and I'm looking forward to find out a solution.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I didn't say to use different names, I said to use different id values. The names can stay the same.
 
Enrique Villamizar
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh, I see...sorry for not paying attention!

Thank you.

Enrique Villamizar
 
Or we might never have existed at all. Freaky. So we should cherish everything. Even this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic