0
我想在MVC4項目中使用jQUery.validate。我有一個嚮導(從stepy開始),我有6個步驟可以完成。在每一步我想添加驗證。現在驗證工作,直到我用一個複選框。 在第2步我有一個複選框。當我然後想繼續步驟3它給了我錯誤: 無法讀取未定義的屬性名稱。jQuery.Validate在MVC4
當我刪除複選框一切工作正常。此外,當我運行HTML它的作品,但如果我把它放入MVC剃刀它失敗。
任何幫助表示讚賞。
感謝
這是HTML + jQuery的:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="-1">
<title>jQuery Stepy - A Wizard Plugin</title>
<link type="text/css" rel="stylesheet" href="css/jquery.stepy.css" />
<script type="text/javascript" src="js/jquery-1.8.2.js"></script>
<script type="text/javascript" src="js/jquery.validate.min.js"></script>
<script type="text/javascript" src="js/jquery.stepy.min.js"></script>
<script type="text/javascript">
$(function() {
$('#custom').stepy({
backLabel: 'Backward',
block: true,
errorImage: true,
nextLabel: 'Forward',
titleClick: true,
validate: true
});
// Optionaly
$('#custom').validate({
rules: {
'checked': 'required',
}, messages: {
'checked': { required: 'error' },
}
});
});
</script>
</head>
<body>
<div id="header">
</div>
<div id="content">
<form id="custom">
<fieldset title="Thread 1">
<legend>description one</legend>
<label>User:</label>
<!-- Hidden fields are not focused. -->
<input type="hidden" name="hidden" />
<!-- Disabled fields are not validated. -->
<input type="text" value="wbotelhos" size="40" name="user" disabled="disabled" />
<label>E-mail:</label>
<input type="text" size="40" name="email" />
<input type="checkbox" name="checked" /> Checked?
<label>Naa:</label>
<input type="text" size="40" name="Naam" />
<label>Newsletter?</label>
<input type="radio" name="newsletter" /> Yep
<input type="radio" name="newsletter" /> Nop
<label>Password:</label>
<input type="password" name="password" size="40" />
</fieldset>
<fieldset title="Thread 2">
<legend>description two</legend>
<label>Nick Name:</label>
<input type="text" size="30" />
<label>Bio:</label>
<textarea name="bio" rows="5" cols="60"></textarea>
</fieldset>
<fieldset title="Thread 3">
<legend>description three</legend>
<label>Birthday:</label>
<select name="day">
<option></option>
<option>23</option>
</select>
<select>
<option>10</option>
</select>
<select>
<option>1984</option>
</select>
<label>Site:</label>
<input type="text" name="site" size="40" />
</fieldset>
<input type="submit" class="finish" value="Finish!" />
</form><br/>
</body>
你能發表一些代碼示例嗎? –