Reputation: 821
I am using the jQuery Validation plugin (v1.12.0) to validate an HTML form.
When using the default validate()
method on the form (without any rules), it checks the text inputs for min/max values and, since the input value is a string, returns the following message: Please enter a value greater than or equal to 0.
Any idea what causes this behavior, and how I can stop the plugin from automatically validating these inputs so it only validates according to what's specified in the rules
object?
Following is the code that reproduces the issue:
<html>
<head>
<title>Validation Test Page</title>
</head>
<body>
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="jquery.validate.min.js"></script>
<div id="main_div">
<div id="content_div">
<h2 id="title">Validation Test Page</h2>
<form id="new_customer_form" class="validate" action="generate.php" method="post" enctype="multipart/form-data">
Customer Name: <input id="inp_cust_name" class="tooltip" type="text"
name="inp_cust_name">
Title: <input id="inp_title" class="tooltip" type="text" name="inp_title"><br>
Custom text: <textarea id="inp_text" class="tooltip" name="inp_text" placeholder="Enter text here"></textarea><br>
Customer logo: <input id="inp_file" class="tooltip" type="file" name="inp_file"><br>
<div id="action_div_create">
<input id="inp_submit" type="submit" name="inp_submit" value="Submit">
<a href="./"><button type="button">Cancel</button></a>
</div>
</form>
<script>
$(document).ready(function() {
$("#new_customer_form").validate({
rules: {
inp_cust_name : {
required: true
}
}
});
});
</script>
</div>
</div>
</body>
</html>
Upvotes: 2
Views: 1352
Reputation: 821
This was happening when using jQuery 1.3.2. When changing to jQuery 1.11.1 the issue disappeared. This could be a bug or something else - please feel free to add any useful information if you have any.
Upvotes: 1