Execute
Save
Share
Share link
share
share
share
Team
Public Teams
Comments
0
Created By:
Guest
Title:
Date Validation Form Submit
Title
Description
Edit
Copy Link
Login
Email *
Password *
Login
OR
Create Account
Screen Name *
Email *
Password *
Retype Password *
Team Access Code
Register
Public CodeBins
HELP
--Select Theme--
Ambiance
Blackboard
Cobalt
Eclipse
Elegant
Erlang-Dark
Lesser-Dark
Monokai
Neat
Night
Rubyblue
Vibrant-Ink
Xq-Dark
New CodeBin
CodeBins Versions
Date Validation- V.2
Date Validation- V.1
Compare Versions
Recent CodeBins
View All CodeBins
jQuery.validator.setDefaults({ success: "valid" }); ; $.validator.addMethod( "regex", function (value, element, regexp) { var re = new RegExp(regexp); return this.optional(element) || re.test(value); }, "Please check your input." ); /** * @author GeekTantra * @date 24 September 2009 */ /* * This functions checks where an entered date is valid or not. * It also works for leap year feb 29ths. * @year: The Year entered in a date * @month: The Month entered in a date * @day: The Day entered in a date */ function isValidDate(year, month, day) { var date = new Date(year, (month - 1), day); var DateYear = date.getFullYear(); var DateMonth = date.getMonth(); var DateDay = date.getDate(); if (DateYear == year && DateMonth == (month - 1) && DateDay == day) return true; else return false; } /* * This function checks if there is at-least one element checked in a group of * check-boxes or radio buttons. * @id: The ID of the check-box or radio-button group */ function isChecked(id) { var ReturnVal = false; $("#" + id).find('input[type="radio"]').each(function () { if ($(this).is(":checked")) ReturnVal = true; }); $("#" + id).find('input[type="checkbox"]').each(function () { if ($(this).is(":checked")) ReturnVal = true; }); return ReturnVal; } $.validator.addMethod( "totalValidationDate", function (value, element) { return isValidDate(parseInt(value.split('/')[2]), parseInt(value.split('/')[0]), parseInt(value.split('/')[1])) || this.optional(element); }, "Please enter a date in the format mm/dd/yyyy" ); $(document).ready(function () { $("#commentForm").validate({ rules: { date1: { required: true, totalValidationDate: true }, textBox1: { regex: "^[a-zA-Z'.\\s]{1,40}$" } } }); }); $(document).ready(function () { $("#date1").datepicker(); });
Bottom of Page
In Head
On Load
On Ready
Setting
Validate
Copy
Format
Setting
Validate
Copy
Format
<script type="text/javascript" src="http://jzaefferer.github.com/jquery-validation/jquery.validate.js"></script> <form id="commentForm" method="get" action="http://www.yahoo.com"> <input type="text" name="date1" id="date1" /> <input type="text" name="textBox1" id="textBox1" /> <input type="submit" value="Submit" id="btnSubmit"/> </form>
No Doc Type
HTML5
HTML 4.01 Transitional
HTML 4.01 Strict
HTML 4.01 Frameset
XHTML 1.1
XHTML 1.0 Transitional
XHTML 1.0 Strict
XHTML 1.0 Frameset
Copy
Format
Download
×
Code Description
×
Difference of Versions
HTML
CSS
JS
×
JS Error
×
CSS Error
Errors
Warnings
×
JavaScript Setting
JS Libraries:
Chrome Frame 1.0.3
Dojo 1.8.0
Dojo 1.7.3
Dojo 1.7.2
Ext Core 3.1.0
jQuery 1.8.0
jQuery 1.7.2
jQuery 1.6.0
jQuery 1.5.0
jQuery 1.4.4
jQuery 1.4.0
jQuery-min 1.7.2
jQueryUI-min 1.8.21
MooTools more-1.4.0.1-full
MooTools core-1.4.5-full
MooTools core-1.4.1-full
Prototype 1.7.1.0
script.aculo.us 1.9.0
SWFObject 2.2
Twitter Bootstrap 2.0.4
WebFont Loader 1.0.28
yui 3.5.1
User Libraries:
Upload File
JavaScript URL(s):
×
CSS Setting
CSS Libraries:
jQueryUI 1.8.21
Twitter Bootstrap 2.0.4
User Libraries:
Upload File
CSS URL(s):