View Single Post
  #6 (permalink)  
Old Apr 22nd, 2008, 08:14
spinal007's Avatar
spinal007 spinal007 is offline
Moderator
Join Date: Mar 2004
Location: Good Ol'London
Age: 22
Posts: 1,617
Blog Entries: 1
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via ICQ to spinal007 Send a message via MSN to spinal007 Send a message via Yahoo to spinal007 Send a message via Skype™ to spinal007
Re: help with checkbox and textfield in form

- Add an id to your checkbox:
<input name='oth' id='oth'

- Add an id to your textbox:
<input type='text' name='other' id='other'

- Use this to checked whether the 'other' textbox is selected:
document.getElementById('oth').checked

- Slight change to aso's suggestion, which will work on if textfield.value is empty or null
(textfield.value || '').length <= 0

- Another change to aso's suggestion: checked AND empty (not OR)

- Then you end up with this:
Code: Select all
if(document.getElementById('oth').checked && (document.getElementById('other').value || '').length <= 0) {
 return false;
}
You should be able to make this work now...
Reply With Quote