: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* jQuery Validation Plugin v1.12.0
* http://jqueryvalidation.org/
* Copyright (c) 2014 Jörn Zaefferer
* Released under the MIT license
// http://jqueryvalidation.org/validate/
validate: function( options ) {
// if nothing is selected, return nothing; can't chain anyway
if ( options && options.debug && window.console ) {
console.warn( "Nothing selected, can't validate, returning nothing." );
// check if a validator for this form was already created
var validator = $.data( this[0], "validator" );
// Add novalidate tag if HTML5.
this.attr( "novalidate", "novalidate" );
validator = new $.validator( options, this[0] );
$.data( this[0], "validator", validator );
if ( validator.settings.onsubmit ) {
this.validateDelegate( ":submit", "click", function( event ) {
if ( validator.settings.submitHandler ) {
validator.submitButton = event.target;
// allow suppressing validation by adding a cancel class to the submit button
if ( $(event.target).hasClass("cancel") ) {
validator.cancelSubmit = true;
// allow suppressing validation by adding the html5 formnovalidate attribute to the submit button
if ( $(event.target).attr("formnovalidate") !== undefined ) {
validator.cancelSubmit = true;
// validate the form on submit
this.submit( function( event ) {
if ( validator.settings.debug ) {
// prevent form submit to be able to see console output
if ( validator.settings.submitHandler ) {
if ( validator.submitButton ) {
// insert a hidden input as a replacement for the missing submit button
hidden = $("<input type='hidden'/>").attr("name", validator.submitButton.name).val( $(validator.submitButton).val() ).appendTo(validator.currentForm);
validator.settings.submitHandler.call( validator, validator.currentForm, event );
if ( validator.submitButton ) {
// and clean up afterwards; thanks to no-block-scope, hidden can be referenced
// prevent submit for invalid forms or custom submit handlers
if ( validator.cancelSubmit ) {
validator.cancelSubmit = false;
if ( validator.form() ) {
if ( validator.pendingRequest ) {
validator.formSubmitted = true;
validator.focusInvalid();
// http://jqueryvalidation.org/valid/
if ( $(this[0]).is("form")) {
valid = this.validate().form();
validator = $(this[0].form).validate();
valid = validator.element(this) && valid;
// attributes: space separated list of attributes to retrieve and remove
removeAttrs: function( attributes ) {
$.each(attributes.split(/\s/), function( index, value ) {
result[value] = $element.attr(value);
$element.removeAttr(value);
// http://jqueryvalidation.org/rules/
rules: function( command, argument ) {
settings, staticRules, existingRules, data, param, filtered;
settings = $.data(element.form, "validator").settings;
staticRules = settings.rules;
existingRules = $.validator.staticRules(element);
$.extend(existingRules, $.validator.normalizeRule(argument));
// remove messages from rules, but allow them to be set separately
delete existingRules.messages;
staticRules[element.name] = existingRules;
if ( argument.messages ) {
settings.messages[element.name] = $.extend( settings.messages[element.name], argument.messages );
delete staticRules[element.name];
$.each(argument.split(/\s/), function( index, method ) {
filtered[method] = existingRules[method];
delete existingRules[method];
if ( method === "required" ) {
$(element).removeAttr("aria-required");
data = $.validator.normalizeRules(
$.validator.classRules(element),
$.validator.attributeRules(element),
$.validator.dataRules(element),
$.validator.staticRules(element)
// make sure required is at front
data = $.extend({ required: param }, data );
$(element).attr( "aria-required", "true" );
// make sure remote is at back
data = $.extend( data, { remote: param });
// http://jqueryvalidation.org/blank-selector/
blank: function( a ) { return !$.trim("" + $(a).val()); },
// http://jqueryvalidation.org/filled-selector/
filled: function( a ) { return !!$.trim("" + $(a).val()); },
// http://jqueryvalidation.org/unchecked-selector/
unchecked: function( a ) { return !$(a).prop("checked"); }
// constructor for validator
$.validator = function( options, form ) {
this.settings = $.extend( true, {}, $.validator.defaults, options );
// http://jqueryvalidation.org/jQuery.validator.format/
$.validator.format = function( source, params ) {
if ( arguments.length === 1 ) {
var args = $.makeArray(arguments);
return $.validator.format.apply( this, args );
if ( arguments.length > 2 && params.constructor !== Array ) {
params = $.makeArray(arguments).slice(1);
if ( params.constructor !== Array ) {
$.each(params, function( i, n ) {
source = source.replace( new RegExp("\\{" + i + "\\}", "g"), function() {
errorLabelContainer: $([]),
onfocusin: function( element ) {
this.lastActive = element;
// hide error label and remove error class on focus if enabled
if ( this.settings.focusCleanup && !this.blockFocusCleanup ) {
if ( this.settings.unhighlight ) {
this.settings.unhighlight.call( this, element, this.settings.errorClass, this.settings.validClass );
this.addWrapper(this.errorsFor(element)).hide();
onfocusout: function( element ) {
if ( !this.checkable(element) && (element.name in this.submitted || !this.optional(element)) ) {
onkeyup: function( element, event ) {
if ( event.which === 9 && this.elementValue(element) === "" ) {
} else if ( element.name in this.submitted || element === this.lastElement ) {
onclick: function( element ) {
// click on selects, radiobuttons and checkboxes
if ( element.name in this.submitted ) {
// or option elements, check parent select in that case
} else if ( element.parentNode.name in this.submitted ) {
this.element(element.parentNode);
highlight: function( element, errorClass, validClass ) {
if ( element.type === "radio" ) {
this.findByName(element.name).addClass(errorClass).removeClass(validClass);
$(element).addClass(errorClass).removeClass(validClass);
unhighlight: function( element, errorClass, validClass ) {
if ( element.type === "radio" ) {
this.findByName(element.name).removeClass(errorClass).addClass(validClass);
$(element).removeClass(errorClass).addClass(validClass);
// http://jqueryvalidation.org/jQuery.validator.setDefaults/
setDefaults: function( settings ) {
$.extend( $.validator.defaults, settings );
required: "This field is required.",
remote: "Please fix this field.",
email: "Please enter a valid email address.",
url: "Please enter a valid URL.",
date: "Please enter a valid date.",
dateISO: "Please enter a valid date (ISO).",
number: "Please enter a valid number.",
digits: "Please enter only digits.",
creditcard: "Please enter a valid credit card number.",
equalTo: "Please enter the same value again.",
maxlength: $.validator.format("Please enter no more than {0} characters."),
minlength: $.validator.format("Please enter at least {0} characters."),
rangelength: $.validator.format("Please enter a value between {0} and {1} characters long."),
range: $.validator.format("Please enter a value between {0} and {1}."),
max: $.validator.format("Please enter a value less than or equal to {0}."),
min: $.validator.format("Please enter a value greater than or equal to {0}.")
this.labelContainer = $(this.settings.errorLabelContainer);
this.errorContext = this.labelContainer.length && this.labelContainer || $(this.currentForm);
this.containers = $(this.settings.errorContainer).add( this.settings.errorLabelContainer );
var groups = (this.groups = {}),
$.each(this.settings.groups, function( key, value ) {
if ( typeof value === "string" ) {
value = value.split(/\s/);
$.each(value, function( index, name ) {
rules = this.settings.rules;
$.each(rules, function( key, value ) {
rules[key] = $.validator.normalizeRule(value);
function delegate(event) {
var validator = $.data(this[0].form, "validator"),
eventType = "on" + event.type.replace(/^validate/, ""),
settings = validator.settings;
if ( settings[eventType] && !this.is( settings.ignore ) ) {
settings[eventType].call(validator, this[0], event);
.validateDelegate(":text, [type='password'], [type='file'], select, textarea, " +
"[type='number'], [type='search'] ,[type='tel'], [type='url'], " +
"[type='email'], [type='datetime'], [type='date'], [type='month'], " +
"[type='week'], [type='time'], [type='datetime-local'], " +
"[type='range'], [type='color'] ",
"focusin focusout keyup", delegate)
.validateDelegate("[type='radio'], [type='checkbox'], select, option", "click", delegate);
if ( this.settings.invalidHandler ) {
$(this.currentForm).bind("invalid-form.validate", this.settings.invalidHandler);
// Add aria-required to any Static/Data/Class required fields before first validation
// Screen readers require this attribute to be present before the initial submission http://www.w3.org/TR/WCAG-TECHS/ARIA2.html
$(this.currentForm).find("[required], [data-rule-required], .required").attr("aria-required", "true");
// http://jqueryvalidation.org/Validator.form/
$.extend(this.submitted, this.errorMap);
this.invalid = $.extend({}, this.errorMap);
$(this.currentForm).triggerHandler("invalid-form", [ this ]);
for ( var i = 0, elements = (this.currentElements = this.elements()); elements[i]; i++ ) {
this.check( elements[i] );
// http://jqueryvalidation.org/Validator.element/
element: function( element ) {
var cleanElement = this.clean( element ),
checkElement = this.validationTargetFor( cleanElement ),
this.lastElement = checkElement;
if ( checkElement === undefined ) {
delete this.invalid[ cleanElement.name ];
this.prepareElement( checkElement );
this.currentElements = $( checkElement );
result = this.check( checkElement ) !== false;
delete this.invalid[checkElement.name];
this.invalid[checkElement.name] = true;
// Add aria-invalid status for screen readers
$( element ).attr( "aria-invalid", !result );
if ( !this.numberOfInvalids() ) {
// Hide error containers on last error
this.toHide = this.toHide.add( this.containers );
// http://jqueryvalidation.org/Validator.showErrors/
showErrors: function( errors ) {
// add items to error list and map
$.extend( this.errorMap, errors );
for ( var name in errors ) {
element: this.findByName(name)[0]
// remove items from success list
this.successList = $.grep( this.successList, function( element ) {
return !(element.name in errors);
if ( this.settings.showErrors ) {
this.settings.showErrors.call( this, this.errorMap, this.errorList );
this.defaultShowErrors();
// http://jqueryvalidation.org/Validator.resetForm/
$(this.currentForm).resetForm();
.removeClass( this.settings.errorClass )
.removeData( "previousValue" )
.removeAttr( "aria-invalid" );
numberOfInvalids: function() {
return this.objectLength(this.invalid);
objectLength: function( obj ) {
/* jshint unused: false */
this.addWrapper( this.toHide ).hide();
return this.size() === 0;
return this.errorList.length;
focusInvalid: function() {
if ( this.settings.focusInvalid ) {
$(this.findLastActive() || this.errorList.length && this.errorList[0].element || [])
// manually trigger focusin event; without it, focusin handler isn't called, findLastActive won't have anything to find
// ignore IE throwing errors when focusing hidden elements
findLastActive: function() {
var lastActive = this.lastActive;