私のコードです
<div class="rButtons">
<input type="radio" name="numbers" value="10" onclick="uncheck();" />10
<input type="radio" name="numbers" value="20" onclick="uncheck();" />20
<input type="radio" name="numbers" value="other" onclick="check(this);"/>other
<input type="text" id="other_field" name="other_field" onblur="checktext(this);"/>
</div>
これはcssコードです
<style type="text/css">
#other_field
{
visibility: hidden;
}
</style>
これはjsです
<script type="text/javascript">
function uncheck()
{
document.getElementById('other_field').style.visibility = "hidden";
}
function check(inputField)
{
if(inputField.checked)
{
document.getElementById('other_field').style.visibility = "visible";
}
}
function checktext(inputField)
{
if(isNaN(inputField.value))
{
alert('only numbers are allowed..');
return false;
}
else if( (inputField.value % 10 ) != 0)
{
alert('only multiples of 10..');
return false;
}
else
{
return true;
}
}
</script>
すべてが順調です..しかし問題はこれです..[その他]ラジオボタンをクリックすると新しい空白のフィールドが開きますが、10または20に戻るとそこにとどまります..これを非表示にするにはどうすればよいですか?
私は答えが簡単であることを知っています..しかし、私は多くのことを試みましたが、うまくいきませんでした..
ありがとう