Hy! 我做了一個簡單的表單,幷包括我的js驗證文件,但它不工作。 我甚至包括所有必需的腳本和css文件,但它給出了錯誤。 在控制檯上的錯誤是表單驗證不起作用
最大調用堆棧大小超過
我沒有找到任何解決辦法呢!
form_validation.js
$(document).ready(function() {
$('#contactForm')
.formValidation({
icon: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
name: {
validators: {
notEmpty: {
message: 'The first name is required'
},
regexp: {
message: 'Name only contains Letter',
regexp: /^[A-Za-z]*$/
}
}
},
message: {
validators: {
notEmpty: {
message: 'The message is required'
},
}
}
}
})
});
testForm.php
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<meta charset="UTF-8">
<title></title>
<link type="text/css" rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<link href="http://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" type="text/ecmascript"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<script src="http://formvalidation.io/vendor/formvalidation/js/formValidation.min.js"></script>
<script src="http://formvalidation.io/vendor/formvalidation/js/framework/bootstrap.min.js"></script>
<script src="js/form_validation.js"></script>
</head>
<body>
<form method="post" id="contactForm" >
<label>Name</label>
<input type="text" name="name"/>
<input type="submit" value="process"/>
</form>
</body>
</html>
我舉辦了一個猜測。 請改變這個標記的名稱屬性的值 不要忘記在form_validation.js中更改.. :) –