任何人都知道如何检查所有字段都填充了某个下拉列表中的第二级字段?我尝试了一种来自互联网的方法,但它检查了所有字段,包括隐藏字段。如何查看可见的字段?
这是我的代码:
所有表单字段都是必填字段。
<form id="FORM" name="frmname" action="./../ScheduleServlet" method="post">
<fieldset>
<table style="width: 600px">
<tr>
<td style="width: 200px"><label for="jobName">Job Name</label></td>
<td><input type="text" name="jobName" id="jobName"
class="text ui-widget-content ui-corner-all" /></td>
</tr>
<tr id="option0" >
<td><label for="ProfileName">Profile Name</label></td>
<td><select id="ProfileName" name="ProfileName">
<option >...Choose Profile Name...</option>
<%
try{
OverlayManager overlayMgr = new OverlayManager();
ArrayList<OverlayDTO> currentList = overlayMgr.findAllOverlay();
String name = "";
for(int i = 0; i<currentList.size(); i++)
{
name = currentList.get(i).getProfileName();
System.out.println("Here is name : "+name);
%>
<option ><%=name%></option>
<% }
}
catch(Exception e)
{
out.println("Error" +e);
}
%>
</select></td>
</tr>
<tr>
<td><label for="ScheduleType">Scheduled Type</label></td>
<td><select id="ScheduleType" name="ScheduleType">
<option value="0">---Choose a type---</option>
<option value="1">Custom (Adhoc / Run Once)</option>
<option value="2">Hourly</option>
<option value="3">Daily</option>
<option value="4">Weekly</option>
<option value="5">Monthly</option>
</select></td>
</tr>
<tr id="option1" style="display: none;">
<td><label for="hour">Hour</label></td>
<td><input type="number" name="hour" id="hour" value=""
class="text ui-widget-content ui-corner-all" /></td>
</tr>
<tr id="option3" style="display: none;">
<td><label for="Weekly">Weekly</label></td>
<td><select id="dayofWeek" name="dayofWeek">
<option value="1">Monday</option>
<option value="2">Tuesday</option>
<option value="3">Wednesday</option>
<option value="4">Thursday</option>
<option value="5">Friday</option>
<option value="6">Saturday</option>
<option value="7">Sunday</option>
</select></td>
</tr>
<tr id="option4" style="display: none;">
<td><label for="Monthly">Monthly</label></td>
<td><select id="dateofMonth" name="dateofMonth">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
<option value="LD">Last Day</option>
</select></td>
</tr>
<tr id="option5" style="display: none;">
<td><label for="Adhoc">Adhoc</label></td>
<td>
<input type="text" id="datetext" name="datetext" />
</td>
<td>
<input type="hidden" id="date" name="date" />
</td>
</tr>
<tr>
<td><label for="scheduleTime">Scheduled Time</label></td>
<td>
<div id="container">
<div class="example">
<input id="myPicker" class="time" type="text" style=" height : 22px;"/></div>
</div>
</td>
</tr>
<tr>
<td><label for="retry">Retry</label></td>
<td><input type="number" name="retry" id="retry" value=""
class="text ui-widget-content ui-corner-all" /></td>
</tr>
<tr>
<td><label for="sRemarks">Remarks</label></td>
<td><input type="text" name="sRemarks" id="sRemarks" value=""
class="text ui-widget-content ui-corner-all" /></td>
</tr>
</table>
<div data-role="controlgroup" id="ScheduleButtons"
data-type="horizontal" data-mini="true" align="center"
style="width: 500px">
<a href="#" onClick="createSchedule()" data-role="button" data-icon="check"
style="width: 100px">Save </a>
<a href="#" onClick="closewindow()" data-role="button"
data-icon="delete" style="width: 100px">Cancel </a>
</div>
</fieldset>
</form>
<script>
$(function() {
$("#myPicker").timepicker();});
</script>
<script>
function checkDate(ExpDate){
// define date string to test
var ExpiryDate = document.getElementById(ExpDate).value;
// check date and print message
if (isDate(ExpiryDate)) {
// alert('OK');
}
else {
alert('invalidDateErr');
if(ExpDate=="datepicker1"){
document.myform.optthree1.value = "";
}
else{
document.myform.optthree2.value = "";
}
}
}
document.getElementById('ScheduleType').onchange = function(){
if (this.value == '2') {
document.getElementById('option1').style.display = "";
document.getElementById('option3').style.display = "none";
document.getElementById('option4').style.display = "none";
document.getElementById('option5').style.display = "none";
}else if (this.value == '4') {
document.getElementById('option3').style.display = "";
document.getElementById('option1').style.display = "none";
document.getElementById('option4').style.display = "none";
document.getElementById('option5').style.display = "none";
}
else if (this.value == '5') {
document.getElementById('option4').style.display = "";
document.getElementById('option1').style.display = "none";
document.getElementById('option3').style.display = "none";
document.getElementById('option5').style.display = "none";
}
else if (this.value == '1') {
document.getElementById('option5').style.display = "";
document.getElementById('option1').style.display = "none";
document.getElementById('option3').style.display = "none";
document.getElementById('option4').style.display = "none";
}
else {
document.getElementById('option1').style.display = "none";
document.getElementById('option3').style.display = "none";
document.getElementById('option4').style.display = "none";
document.getElementById('option5').style.display = "none";
}};</script><script type="text/javascript">
function createSchedule()
{
var incomplete = $('FORM :input').filter(function() {
return $(this).val() == '';
});
//if incomplete contains any elements, the form has not been filled
if(incomplete.length) {
alert('please fill out the form');
//to prevent submission of the form
return false;
}
else{
var sName = document.getElementById("jobName").value;
//var sProfile = document.getElementById("sProfileName").value;
var h = document.getElementById("ProfileName");
var sProfile = h.options[h.selectedIndex].value;
var hour = document.getElementById("hour").value;
var date = document.getElementById("date").value;
var time = document.getElementById("myPicker").value;
var retry = document.getElementById("retry").value;
var sRemarks = document.getElementById("sRemarks").value;
var g = document.getElementById("ScheduleType");
var sTypeID = g.options[g.selectedIndex].value;
var f = document.getElementById("dayofWeek");
var dayofWeek = f.options[f.selectedIndex].value;
var e = document.getElementById("dateofMonth");
var dateofMonth = e.options[e.selectedIndex].value;
//alert('here!!!'+dateofMonth);
$.ajax({
type: "GET",
async: false,
dataType: "text",
url: "./../ScheduleServlet",
data: {ActionType:"1",sName:sName,sProfile:sProfile,sTypeID:sTypeID,hour:hour,dayofWeek:dayofWeek,dateofMonth:dateofMonth,date:date,time:time,retry:retry,sRemarks:sRemarks},
success: function(TokenData){
// alert("response data: "+TokenData);
if(TokenData != null){
returnValue = TokenData;
alert("Successfully Saved!");
url: "./../ScheduleServlet",
window.opener.location.reload(false);
window.close();
}
}
});
//alert("data is :"+returnValue);
return returnValue;
}
}
function closewindow(){
var ans = window.confirm("Are you sure you want to cancel?")
if(ans){
window.close();
}
}