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

Q1199 How can I restrict data entry into two text fields based on two radio buttons?

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

Q1199 How can I restrict data entry into two text fields based on two radio buttons?

In HTML4.0 someting like this work:

<html>
<form name="myform">
<input type="radio" name="enable" checked
    onClick="this.form.f1.disabled=false;
             this.form.f2.disabled=true;
             this.form.f1.focus();">
<input type="text" name="f1" value=""
    onKeyUp="if (this.disabled) this.value=''">
<br>
<input type="radio" name="enable"
    onClick="this.form.f1.disabled=true;
             this.form.f2.disabled=false;
             this.form.f2.focus();">
<input type="text" disabled name="f2" value=""
    onKeyUp="if (this.disabled) this.value=''">
</form>

<script language="JavaScript"><!--
document.myform.f1.disabled=false; // initial value for NS
document.myform.f2.disabled=true;  // initial value for NS
//--></script>

</html>

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.