- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我对此脚本有疑问,我需要底部编程的表单验证器首先检查带有选择的 radio 是否是目标,然后才从该特定 radio 下拉列表中请求时间。如果我能得到:
if (document.getElementById('first').checked) {
frmvalidator.addValidation("selects", "dontselect=000", "select a time");
}
声明在javascript中工作,但因为它只寻找真实的时间,但我似乎遗漏了一些东西。请帮忙
<form method="POST" name="contactform" id="contactform" action="contact-form-handler.php">
<div>
<div style="float:left; width:420px;";>
<input type="radio" name="radios" id="first" value="SELECT" /> Attending a GROUP Intro to Meditation ($15) on: <br/>
<select name="selects"id="selects">
<option value="000">Select a Date</option>
<option value="2">April 23rd, TUES at 7:00PM - Group Intro to Meditation</option>
<option value="3">April 27th, SAT at 11:00AM - Group Intro to Meditation</option>
<option value="4">May 1st, WED at 7:00PM - Group Intro to Meditation</option>
<option value="5">May 7th, TUES at 7:00PM - Group Intro to Meditation</option>
</select>
<br>
<input type="radio" name="radios" value="radio1" /> Scheduling a PRIVATE Intro to Meditation ($200) <br/>
<input type="radio" name="radios" value="radio2" /> Scheduling an Individual Consultation ($300 / $475) <br/>
<input type="radio" name="radios" value="radio3" /> GIFT a Mentoring Session - 2 hr ($350) <br>
<input type="radio" name="radios" value="radio4" /> Corporate Programs <br/>
<input type="radio" name="radios" value="radio5" /> Pro Bono Programs <br/>
<input type="radio" name="radios" value="radio6" /> General Inquiry <br/>
<input type="radio" name="radios" value="radio7" /> Receiving Information on Future Intro Dates<br/>
</div>
<div style="float:left";>
<label for='name'>Your Name: </label>
<input type="text" name="name"> <br>
<label for='email'>Email Address: </label>
<input type="text" name="email"> <br>
<label for='confirm_email'>Confirm Email:</label>
<input type="text" name="confirm_email"> <br>
<label for='email'>Contact #: </label>
<input type="text" name="contact"> <br>
<label for='message'>Message:</label> <br>
<textarea rows="8" cols="35" name="message";></textarea>
<input type="submit" value="Submit"><br>
</form>
</div>
</div>
</td>
<tr>
<td>
<script language="JavaScript">
// Code for validating the form
// Visit http://www.javascript-coder.com/html-form/javascript-form-validation.phtml
// for details
var frmvalidator = new Validator("contactform");
frmvalidator.addValidation("name","req","Please provide your name");
frmvalidator.addValidation("email","req","Please provide your email");
frmvalidator.addValidation("email","email","Please enter a valid email address");
//frmvalidator.addValidation("selects","dontselect=000","select a time");
var chktestValidator = new Validator("contactform");
//chktestValidator.addValidation("radios","selectradio","Please select an option");
chktestValidator.addValidation("radios","selone", "Please select a plan");
if(document.getElementById('first').checked) {
frmvalidator.addValidation("selects","dontselect=000","select a time");
}
</script>
最佳答案
在我看来,您真正想要的是 id“first”的单选按钮上的监听器,当选中该按钮时,根据按钮是否被选中来启用或禁用相邻的选择元素。您可以通过以下方式做到这一点:
<input type="radio" ... onclick="this.form.selects.disabled = !this.checked;">
当页面通过脚本加载时,您应该禁用 select 元素,而不是在 HTML 中。
在 select 元素中,您应该将 HTML 中的第一个选项设置为选中:
<option value="000" selected>Select a Date</option>
关于javascript - 表单验证器检查选项并选择检查不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16268410/
今天有小伙伴给我留言问到,try{...}catch(){...}是什么意思?它用来干什么? 简单的说 他们是用来捕获异常的 下面我们通过一个例子来详细讲解下
我正在努力提高网站的可访问性,但我不知道如何在页脚中标记社交媒体链接列表。这些链接指向我在 facecook、twitter 等上的帐户。我不想用 role="navigation" 标记这些链接,因
说现在是 6 点,我有一个 Timer 并在 10 点安排了一个 TimerTask。之后,System DateTime 被其他服务(例如 ntp)调整为 9 点钟。我仍然希望我的 TimerTas
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我就废话不多说了,大家还是直接看代码吧~ ? 1
Maven系列1 1.什么是Maven? Maven是一个项目管理工具,它包含了一个对象模型。一组标准集合,一个依赖管理系统。和用来运行定义在生命周期阶段中插件目标和逻辑。 核心功能 Mav
我是一名优秀的程序员,十分优秀!