我正在使用此网站http://www.formvalidator.net/index.html来测试我的实时表单验证。我遇到的问题是代码根本不起作用。
这是html页面
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
<form action="" method="POST">
<p>
User name (4 characters minimum, only alphanumeric characters):
<input data-validation="length alphanumeric" data-validation-length="min4">
</p>
<p>
Year (yyyy-mm-dd):
<input data-validation="date" data-validation-format="yyyy-mm-dd">
</p>
<p>
Website:
<input data-validation="url">
</p>
<p>
<input type="submit">
</p>
</form>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-form-validator/2.3.26/jquery.form-validator.min.js"></script>
<script>
$.validate({
lang: 'es'
});
</script>
</body>
</html>
答案 0 :(得分:1)
问题是您没有正确链接脚本,如果您在本地主机中运行它,则忽略http://或https://这很重要。
我测试了它并且它正在工作
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
<form action="" method="POST">
<p>
User name (4 characters minimum, only alphanumeric characters):
<input data-validation="length alphanumeric" data-validation-length="min4">
</p>
<p>
Year (yyyy-mm-dd):
<input data-validation="date" data-validation-format="yyyy-mm-dd">
</p>
<p>
Website:
<input data-validation="url">
</p>
<p>
<input type="submit">
</p>
</form>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery-form-validator/2.3.26/jquery.form-validator.min.js"></script>
<script>
$.validate({
lang: 'es'
});
</script>
</body>
</html>