Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q1666 How can I ensure that a user has checked button, and has selected an item from a select list?

irt.org | Knowledge Base | JavaScript | Form | Q1666 [ previous next ]

Q1666 How can I ensure that a user has checked button, and has selected an item from a select list?

Try something like:

<script language="JavaScript"><!--
function formvalidate(request){
  if (!request.choice[0].checked  && !request.choice[1].checked && !request.choice[2].checked) {
    alert('You must select one of the 3 choices to submit this request.');
    return false;
  }
   
  if (request.selectName[request.selectName.selectedIndex].value == '') {
    alert('You must select one of the options.');
    return false;
  }

  return true;
}
//--></script>

<form onSubmit="return formvalidate(this)">
<input type="radio" name="choice" value="1">
<input type="radio" name="choice" value="2">
<input type="radio" name="choice" value="3">
<select name="selectName">
<option value="">Select One:
<option value="1">1
<option value="2">2
<option value="3">3
</select>
<input type="submit">
</form>

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.