2
jQuery UI 탭과 유효성 검사 플러그인을 함께 사용하고 있습니다. 가상 버튼으로 작동하는 스팬의 click 이벤트에서 유효성을 검사합니다. 첫 번째 탭에 표시되는 폼 요소에 유효성 검사 클래스 만 추가했습니다. 또한 전체 페이지에 대해 하나의 양식이 있습니다. 첫 번째 탭을 보는 동안 버튼을 클릭하면 유효성 검사가 작동하지만 다른 탭을보고있는 경우 버튼을 클릭하면 첫 번째 페이지의 입력이 유효하지 않아도 코드가 실행됩니다. 왜 이런 일이 일어나는 지 알기나 해. 아래는 사이트 전체 코드입니다. 감사!jQuery 탭과 유효성 검사가 함께 작동하지 않습니다.
<!DOCTYPE HTML SYSTEM>
<html>
<head>
<title>Tournament Designer</title>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.21/themes/smoothness/jquery-ui.css" type="text/css" media="all" />
<link type="text/css" rel="stylesheet" href="stylesheet.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.js"></script>
<script type="text/javascript" src="jquery.ui.touch-punch.js"></script>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.js"></script>
<script type="text/javascript" src="code.js"></script>
</head>
<body>
<div class="topBanner">Tournament Designer</div>
<br/>
<span class="relative">
<form id="tournamentDesign" method="post" style="display:inline;">
<span id="result" class="tournamentFinalized absolute">I'm here!</span>
<span id="tournamentDesignTabs">
<ul>
<li><a href="#tabs-1">Details</a></li>
<li><a href="#tabs-2">Pricing & Promo Codes</a></li>
<li><a href="#tabs-3">Divisions</a></li>
<li><a href="#tabs-4">Mats</a></li>
<span id="createTournament" class="pseudoButton">Create Tournament</span>
</ul>
<div id="tabs-1">
<p>Enter the details concerning the tournament name, location, date, etc. here.<br/><em>(* denotes a required field)</em></p>
Tournament Name:<input id="tournamentName" name="tournamentName" value="" class="required"/>*<br/>
District:<select id="district" name="district" value="" class="required">
<option value="0">Provo</option>
<option value="1">SLC</option>
</select>*<br>
Region:<select id="region" name="region" value="" class="required">
<option value="0">West-USA</option>
</select>*<br/>
Location:<input id="location" name="location" value="" class="required"/>*<br/>
Date:<input id="date" name="date" value="" class="required date"/>*<br/>
Time:<input id="startTime" name="startTime" value="" class="required"/>*<br/>
Logo:<input id="logo" name="logo" value="" class="url"/>*<span id="addPicture" onclick="displayPicture('tournamentLogo',document.getElementById('logo').value)" class="pseudoButton">Add</span><span id="removePicture" onclick="removePicture('tournamentLogo')" class="pseudoButton">Remove</span><br/>
<span id="tournamentLogo" class="tournamentLogo"></span>
</div>
<div id="tabs-2">
<p>Set the pricing structure here. You can add as many structures as you like. To remove a structure select it in the textbox below including the comma and delete it.</p>
# of Divisions:<input id="divisionCount" name="divisionCount" value="" size="3"/> Price:<input id="divisionPrice" name="divisionPrice" value="" size="3"/><span id="addDivisionPricing" onclick="addDivisionPricing()" class="pseudoButton">Add</span><br/>
Pricing Structures:<br/>
<span id="divisionPricingInfo" name="divisionPricingInfo" class="divisionPricingInfo"></span><br/>
<p>Add Promo Codes Here. A valid Promo Code will contain any character between A-Z and 0-9. When creating a Promo Code you can set it to discount by a percentage or fixed dollar amount. Percentage is selected by default. To remove a promo code follow the same steps as above.</p>
Promo Codes:</br>
Code:<input id="promoCode" name="promoCode" value="" size="3"/> Discount(Percent<input type="radio" name="percentorDollar" value="0" checked>[%] or Dollars<input type="radio" name="percentorDollar" value="1">[$]): <input id="promoCodeValue" name="promoCodeValue" value="" size="3"/><span id="addPromoCode" onclick="addPromoCode()" class="pseudoButton">Add</span><br/>
<span id="promoCodeInfo" name="promoCodeInfo" class="divisionPricingInfo"></span><br/>
</div>
<div id="tabs-3">
<p>Skill & Weight Divisions</p>
Enter Top Level Divisions Here:<input id="tournamentDivisionInput" value="" size=5><span class="addButton" onclick="addDivisions('tournamentDivisionInfo',document.getElementById('tournamentDivisionInput').value,true)">+</span>
<span id="tournamentDivisionInfo" class="divisionInfo" style="width:800px;"></span>
</div>
<div id="tabs-4">
<p>Mat Design</p>
Add Mat Area <input id="matAreaInput" size=3/> With 4 mats. <span class="pseudoButton" onclick="addMatArea(document.getElementById('matAreaInput').value)">Add</span><br/>
<span class="divisionPricingInfo" id="matAreaInfo"></span>
</div>
</span>
</form>
</span>
<script type="text/javascript">
$("#tournamentDesignTabs").tabs();
$("#tournamentDesign").validate();
$("#createTournament").click(function(){
if($("#tournamentDesign").valid()){
$.post(
"createTournament.php",
{tournamentName: $("#tournamentName").val(), district: $("#district").val(), region: $("#region").val(), location: $("#location").val(), date: $("#date").val(), time: $("#time").val(), logo: $("#logo").val()},
function(responseText){
$("#result").html(responseText);
},
"html" )
$("#result").css('z-index',1000);
$("#result").css('background-color','#000000');
$("#result").css({ opacity: 0.95 });
$("#result").css('color','#FFFFFF');
}
}
);
</script>
</body>
</html>