jisoft / jquery-masked-datevalidator
jQuery form's date validator
Installs: 20
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Language:JavaScript
This package is not auto-updated.
Last update: 2024-12-17 04:26:51 UTC
README
This plugin adds date validation for usage jquery.maskedinput . It can also be used separately for others form's fields.
Usage
- Require jquery and jquery.maskedinput
<script type="text/javascript" src="//code.jquery.com/jquery-2.1.0.js"></script>
<script type="text/javascript" src="//cdn.jsdelivr.net/jquery.maskedinput/1.3.1/jquery.maskedinput.min.js"></script>
- Add date field to your form
<input type="text" id="date">
<div id="error-msg"></div>
- Add masks to maskedinput
$.mask.definitions['y'] = '[12]';
$.mask.definitions['m'] = '[01]';
$.mask.definitions['d'] = '[0-3]';
$("#date").mask("d9.m9.y999"/*, { placeholder: " " }*/);
- Configure date validation
// date as d.m.Y
$.fn.dateValidator({
dateSelector:'#date',
msgSelector:'#error-msg',
dateSeparator:'.',
dateFormat:'dmy'
});
// date as m/d/y
$.fn.dateValidator({
dateSelector:'#date',
msgSelector:'#error-msg',
dateSeparator:'/',
dateFormat:'mdy'
});