Maska даты
HTML
<input type="text" class="it" name="it-date" placeholder="дд.мм.гггг"/>
<div id="error-it-date">?</div>
JavaScript
jQuery('.it').keyup(function()
{
var $ = jQuery;
var mask = /^(0?[1-9]|[12][0-9]|3[01])\.(0?(?:[1-9]|1[0-2]))\.[1-2][0-9]{3}$.[1-2][0-9]{3}$/;
if (!mask.test(this.value))
$('#error-' + (this.id || this.name)).text('Invalid date');
else
$('#error-' + (this.id || this.name)).text('Okay');
});
/**
* @see http://github.com/NV/placeholder.js
*/
jQuery.fn.textPlaceholder = function () {
return this.each(function(){
var that = this;
if (that.placeholder && 'placeholder' in document.createElement(that.tagName)) return;
var placeholder = that.getAttribute('placeholder');
var input = jQuery(that);
if (that.value === '' || that.value == placeholder) {
input.addClass('text-placeholder');
that.value = placeholder;
}
input.focus(function(){
if (input.hasClass('text-placeholder')) {
this.value = '';
input.removeClass('text-placeholder')
}
});
input.blur(function(){
if (this.value === '') {
input.addClass('text-placeholder');
this.value = placeholder;
} else {
input.removeClass('text-placeholder');
}
});
that.form && jQuery(that.form).submit(function(){
if (input.hasClass('text-placeholder')) {
that.value = '';
}
});
});
};
/*
Masked Input plugin for jQuery
Copyright (c) 2007-2013 Josh Bush (digitalbush.com)
Licensed under the MIT license (http://digitalbush.com/projects/masked-input-plugin/#license)
Version: 1.3.1
*/
(function($) {
function getPasteEvent() {
var el = document.createElement('input'),
name = 'onpaste';
el.setAttribute(name, '');
return (typeof el[name] === 'function')?'paste':'input';
}
var pasteEventName = getPasteEvent() + ".mask",
ua = navigator.userAgent,
iPhone = /iphone/i.test(ua),
android=/android/i.test(ua),
caretTimeoutId;
$.mask = {
//Predefined character definitions
definitions: {
'9': "[0-9]",
'a': "[A-Za-z]",
'*': "[A-Za-z0-9]"
},
dataName: "rawMaskFn",
placeholder:...