我試圖讓jQuery驗證與我的單選按鈕形式一起工作。 不過,我在與得到它的工作麻煩,驗證功能不工作,這是我的工作代碼:jQuery驗證問題
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title></title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.8/jquery.validate.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#formq").validate();
});
</script>
<style type="text/css">
<!--
label.error {display: none;}
//-->
</style>
</head>
<body>
<form id="formq" name="formq" action="check.php" method="post">
<fieldset>
<input type="hidden" name="check_submit" value="1" />
<label for="radio-1" tabindex="1" class="circle">Circle</label>
<input type="radio" name="radio-button" id="radio-1" value="Circle" validate="required:true" />
<label for="radio-2" tabindex="2" class="pentagon">Pentagon</label>
<input type="radio" name="radio-button" id="radio-2" value="Pentagon" />
<label for="radio-3" tabindex="3" class="triangle">Triangle</label>
<input type="radio" name="radio-button" id="radio-3" value="Triangle" />
<label for="radio-4" tabindex="4" class="hexagon">Hexagon</label>
<input type="radio" name="radio-button" id="radio-4" value="Hexagon" />
<label for="radio-5" tabindex="5" class="square">Square</label>
<input type="radio" name="radio-button" id="radio-5" value="Square" />
<label for="radio-6" tabindex="6" class="octagon">Octagon</label>
<input type="radio" name="radio-button" id="radio-6" value="Octagon" />
<label for="radio" class="error">Please select your gender</label>
<input class="submit" type="submit" value="Submit"/>
</fieldset>
</form>
</body>
</html>
我不知道它是否只有我,但該文檔是相當複雜的理解。 – tenshimsm 2011-04-19 17:14:42