0
xVal 샘플 프로젝트를 Steve Sanderson’s blog에서 다운로드하여 실행하고 서버 측 유효성 검사가 작동하는지 확인합니다 (제출을 클릭 한 후).하지만 클라이언트 측은 그렇지 않습니다. 내가 소스를 보았고, 생성 된 자바 스크립트를보고 있지만xVal 클라이언트 측 유효성 검사가 작동하지 않습니다.
<script type="text/javascript">xVal.AttachValidator("booking", {"Fields":[{"FieldName":"ClientName","FieldRules":[{"RuleName":"Required","RuleParameters":{}},{"RuleName":"StringLength","RuleParameters":{"MaxLength":"3"}}]},{"FieldName":"NumberOfGuests","FieldRules":[{"RuleName":"Range","RuleParameters":{"Min":"1","Max":"20","Type":"decimal"}},{"RuleName":"DataType","RuleParameters":{"Type":"Integer"}}]},{"FieldName":"ArrivalDate","FieldRules":[{"RuleName":"DataType","RuleParameters":{"Type":"Date"}},{"RuleName":"Required","RuleParameters":{}}]}]})</script>
내보기 코드 :
는<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>
</title><link href="../Content/Site.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/Scripts/jquery-1.2.6.js"></script>
<script type="text/javascript" src="/Scripts/jquery.validate.js"></script>
<script type="text/javascript" src="/Scripts/xVal.jquery.validate.js"></script>
</head>
<body>
<div class="page">
<div id="header">
<div id="title">
</div>
<div id="menucontainer">
</div>
</div>
<div id="main">
<h1>Place a booking</h1>
<form action="/Home/CreateBooking" method="post">
<div>
Your name: <input id="booking_ClientName" name="booking.ClientName" type="text" value="" />
</div>
<div>
Number of guests: <input id="booking_NumberOfGuests" name="booking.NumberOfGuests" type="text" value="" />
</div>
<div>
Expected arrival date: <input id="booking_ArrivalDate" name="booking.ArrivalDate" type="text" value="" />
</div>
<input type="submit" />
</form><script type="text/javascript">xVal.AttachValidator("booking", {"Fields":[{"FieldName":"ClientName","FieldRules":[{"RuleName":"Required","RuleParameters":{}},{"RuleName":"StringLength","RuleParameters":{"MaxLength":"15"}}]},{"FieldName":"NumberOfGuests","FieldRules":[{"RuleName":"Range","RuleParameters":{"Min":"1","Max":"20","Type":"decimal"}},{"RuleName":"DataType","RuleParameters":{"Type":"Integer"}}]},{"FieldName":"ArrivalDate","FieldRules":[{"RuleName":"DataType","RuleParameters":{"Type":"Date"}},{"RuleName":"Required","RuleParameters":{}}]}]})</script>
<div id="footer">
My Sample MVC Application © Copyright 2008
</div>
</div>
</div>
</body>
</html>
우리는 귀하의보기 코드를 볼 수 있습니까? – Gregoire
확실한 여기에 간다 – Omu
모든 것이 괜찮은 것 같습니다. 자바 스크립트를 참조한 적이 있습니까? – Gregoire