I'm using JQuery to validate an HTML form, but the "extension" rule is not working (even though I've included the additional-methods.js
file. I've tested my other "rules" (that also come from that js file), and those seem to work fine, so I'm not sure why the extension one isn't.
Here is the html/JS code:
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/additional-methods.js"></script>
<form method="POST" id="regForm" action="{{ url_for('pipeline') }}">
<div class="tab">
<h3>User Assets:</h3>
<br>
<label>Interval BED File</label>
{{ form.target(placeholder="(e.g. Exome-NGv3.bed)...", oninput="this.className = ''") }}
<div class="form-group required">
<label>Sentieon Package Name</label>
{{ form.sentieon_package_name(placeholder="(e.g. sentieon-genomics-201711.01.tar.gz)...", oninput="this.className = ''") }}
</div>
<div class="form-group required">
<label>Sentieon License Name</label>
{{ form.sentieon_license_name(placeholder="(e.g mylicense.lic)...", oninput="this.className = ''") }}
</div>
</div>
</form>
<script>
$(document).ready(function () {
$('#regForm').validate({ // initialize the plugin
rules: {
sentieon_package_name: {
required: true,
extension: "tar|tar.gz"
},
sentieon_license_name: {
required: true,
extension: "lic"
},
submitHandler: function (form) { // for demo
alert('valid form submitted'); // for demo
return false; // for demo
}
});
});
</script>
I can see that in line 2 of your code, you have an opened <script>
tag. This is what is causing your problems. Change this:
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/additional-methods.js"></script>
<script>
To this:
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/additional-methods.js"></script>
And all your problems will be fixed.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.