Jump to content


Photo

Problem Of Using Dom In Ch.7 Form Validation


  • Please log in to reply
2 replies to this topic

#1 pinkfloyd

pinkfloyd

    New Member

  • Members
  • Pip
  • 1 posts

Posted 26 May 2012 - 07:49 PM

I tried to use DOM instead of innerHTML in the example of Ch.7.
The validation for each input field works fine, but when it comes to the "place order" it failed.

Looks like the problem is DOM... since it's the only thing I did different from the example.

Can anybody tell me why this won't work and share what's the best practice for this situation?

Please find my file in attachment.

Attached Files



#2 drewdin

drewdin

    Super Veteran Member

  • Members
  • PipPipPipPipPipPipPipPipPipPipPip
  • 608 posts
  • Gender:Male
  • Location:Boston

Posted 27 May 2012 - 08:19 AM

I tried to use DOM instead of innerHTML in the example of Ch.7.
The validation for each input field works fine, but when it comes to the "place order" it failed.

Looks like the problem is DOM... since it's the only thing I did different from the example.

Can anybody tell me why this won't work and share what's the best practice for this situation?

Please find my file in attachment.


using firebug i get that helpText on Line 24 is undefined. I'm guessing it has to do with the scope of the variable but I am no Javascript master. Maybe Lemuel could explain better.

Heres line 24:
while (helpText.firstChild){


#3 drewdin

drewdin

    Super Veteran Member

  • Members
  • PipPipPipPipPipPipPipPipPipPipPip
  • 608 posts
  • Gender:Male
  • Location:Boston

Posted 30 May 2012 - 11:28 AM

The object

form["message_help"]
doesn't exist: there is no field with the *name* "message_help". Change this:
<span id="message_help" class="help"></span>
to this:
<span id="message_help" name="message_help" class="help"></span>
etc.


Good catch lemuel, I feel like I should have caught that when i got the undefined error in firebug but i didnt put the time in. I hope the OP reads this




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users