フォームを検証したいのですが、その時に周囲の div が表示されている場合のみです。これは私がこれまでに持っているものです:
function validateForm()
{
var x=document.forms["config"]["itemname5"].value;
if (document.getElementById("customtext").style.display=="block" || x==null)
{
alert("Text box must be filled in");
return false;
}
}
HTML スニペット:
<div class="hide" id="customtext">Enter the text you require on the module. eg. "DAVE" max 6 letters<br />
<input type=text name="itemname5" class="nicebox" value='' maxlength="6" style="font-size:14; font-weight:bold; width:210px; vertical-align:top; height:20px;">
</div>
divが表示されている場合、ユーザーがテキストを入力しておらず、フォームを投稿しないかどうかをユーザーに通知するようにしたいです。
ここにページがあります: http://www.censdigital.com/2012/earplugs-config.html
前もって感謝します!