diff --git a/jquery.h5validate.js b/jquery.h5validate.js
index b151b06..bed4ae0 100644
--- a/jquery.h5validate.js
+++ b/jquery.h5validate.js
@@ -108,7 +108,7 @@
// User needs help. Enable active validation.
$element.addClass(options.settings.activeClass);
- if ($errorID.length) { // These ifs are technically not needed, but improve server-side performance
+ if ($errorID.length) { // These ifs are technically not needed, but improve server-side performance
if ($element.attr('title')) {
$errorID.text($element.attr('title'));
}
@@ -154,10 +154,12 @@
rangeOverflow: validity.rangeOverflow || false,
rangeUnderflow: validity.rangeUnderflow || false,
stepMismatch: validity.stepMismatch || false,
- tooLong: validity.tooLong || false,
+ rangeOverflow: validity.rangeOverflow || false,
+ rangeUnderflow: validity.rangeUnderflow || false,
+ tooHigh: validity.tooHigh || false,
typeMismatch: validity.typeMismatch || false,
- valid: validity.valid || true,
- valueMissing: validity.valueMissing || false
+ valueMissing: validity.valueMissing || false,
+ valid: validity.valid || true
}, validity);
},
@@ -253,13 +255,15 @@
errorIDbare = $this.attr(settings.errorAttribute) || false, // Get the ID of the error element.
errorID = errorIDbare ? '#' + errorIDbare.replace(/(:|\.|\[|\])/g,'\\$1') : false, // Add the hash for convenience. This is done in two steps to avoid two attribute lookups.
required = false,
+ maxlength,
+ min,
+ max,
validity = createValidity({element: this, valid: true}),
- $checkRequired = $(''),
- maxlength;
+ $checkRequired = $('');
/* If the required attribute exists, set it required to true, unless it's set 'false'.
- * This is a minor deviation from the spec, but it seems some browsers have falsey
- * required values if the attribute is empty (should be true). The more conformant
+ * This is a minor deviation from the spec, but it seems some browsers have falsey
+ * required values if the attribute is empty (should be true). The more conformant
* version of this failed sanity checking in the browser environment.
* This plugin is meant to be practical, not ideologically married to the spec.
*/
@@ -277,10 +281,22 @@
maxlength = parseInt($this.attr('maxlength'), 10);
if (!isNaN(maxlength) && value.length > maxlength) {
- validity.valid = false;
+ validity.valid = false;
validity.tooLong = true;
}
+ min = parseInt($this.attr('min'), 10);
+ if(!isNaN(min) && (value < min)) {
+ validity.valid = false;
+ validity.rangeUnderflow = true;
+ }
+
+ max = parseInt($this.attr('max'), 10);
+ if(!isNaN(max) && (value > max)) {
+ validity.valid = false;
+ validity.rangeOverflow = true;
+ }
+
if (required && !value) {
validity.valid = false;
validity.valueMissing = true;
@@ -333,9 +349,9 @@
/**
* Take the event preferences and delegate the events to selected
* objects.
- *
+ *
* @param {object} eventFlags The object containing event flags.
- *
+ *
* @returns {element} The passed element (for method chaining).
*/
delegateEvents: function (selectors, eventFlags, element, settings) {
@@ -359,10 +375,10 @@
},
/**
* Prepare for event delegation.
- *
+ *
* @param {object} settings The full plugin state, including
- * options.
- *
+ * options.
+ *
* @returns {object} jQuery object for chaining.
*/
bindDelegation: function (settings) {
@@ -384,7 +400,7 @@
$forms
.attr('novalidate', 'novalidate')
.submit(checkValidityOnSubmitHandler);
-
+
$forms.find("input[formnovalidate][type='submit']").click(function(){
$(this).closest("form").unbind('submit', checkValidityOnSubmitHandler);
});
@@ -418,9 +434,9 @@
* - prevents submission if any invalid fields are found.
* - Optionally validates all fields.
* - Optionally moves focus to the first invalid field.
- *
- * @param {object} evt The jQuery Event object as from the submit event.
- *
+ *
+ * @param {object} evt The jQuery Event object as from the submit event.
+ *
* @returns {object} undefined if no validation was done, true if validation passed, false if validation didn't.
*/
checkValidityOnSubmitHandler = function(evt) {
@@ -486,10 +502,10 @@
* expressions, and add them to the patternLibrary. Patterns in
* the library are automatically assigned to HTML element pattern
* attributes for validation.
- *
+ *
* @param {Object} patterns A map of pattern names and HTML5 compatible
* regular expressions.
- *
+ *
* @returns {Object} patternLibrary The modified pattern library
*/
addPatterns: function (patterns) {
@@ -506,10 +522,10 @@
* Take a valid jQuery selector, and a list of valid values to
* validate against.
* If the user input isn't in the list, validation fails.
- *
+ *
* @param {String} selector Any valid jQuery selector.
*
- * @param {Array} values A list of valid values to validate selected
+ * @param {Array} values A list of valid values to validate selected
* fields against.
*/
validValues: function (selector, values) {