SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Xbox why have you forsaken me? moospot's Avatar
    Join Date
    Feb 2001
    Location
    Clearwater, FL
    Posts
    3,615
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Quick Form validation Help

    Code:
    if (document.getElementById('layer_s').style.visibility = "visible") {
      if (form.s_size.value == ""){
      alert("You must enter a size for your product.");
      form.s_size.focus();
      return (false);
      } 
     }
    Code:
    <div name="layer_s" id="layer_s" style="visibility: hidden;">
    	  <table>
    	 <tr><td class="arial10bold">Size:  </td><td><input type="text" name="s_size" value="" /></td></tr>
    	</table>
    	 </div>
    When I submit my form, it keeps giving me an alert box. It works when the layer is visible, but when its hidden, it doesn't work. After the alert box pops up, the layer becomes visible because of the focus(). I'm trying to bypass that condition when the layer is hidden.

    Clear as mud?

    TIA

  2. #2
    SitePoint Zealot
    Join Date
    Jul 2002
    Location
    Fort Lauderdale
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    if (document.getElementById('layer_s').style.visibility = "visible") {
      if (form.s_size.value == ""){
      alert("You must enter a size for your product.");
      form.s_size.focus();
      return (false);
      } 
     }
    I'm not sure I understand. It doesn't work when its hidden b/c you're only testing for == "visible"...

    Also, make sure you use == on your first if.

    www.unpossiblemedia.com - A Fort Lauderdale based multimedia company.

  3. #3
    Xbox why have you forsaken me? moospot's Avatar
    Join Date
    Feb 2001
    Location
    Clearwater, FL
    Posts
    3,615
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    IT's weird. It works when the layer is visible OR hidden. I'm actually dumping the layer idea and going with a dynamic page.

    But, I tried the == and it worked. So simple!


Bookmarks

Posting Permissions

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