jQuery Validate Credit Card Expiry Date in Rules addMethod Limit 20 Years in Future -



jQuery Validate Credit Card Expiry Date in Rules addMethod Limit 20 Years in Future -

hi have code on jquery validate rules validator.addmethod allows input check future date on card expiry date i.e. 10/2015 valid, inquire there way add together limit of 20 years in future, @ nowadays come in card expiry date of 10/2099 or more. in advance!

here code have, needs custom message. exceeds date range

<input type="text" name="field_4" id="field_4" value=""> $.validator.addmethod( "future", function (value, element) { var today = new date(); var startdate = new date(today.getfullyear(),today.getmonth(),1,0,0,0,0); var expdate = value; var separatorindex = expdate.indexof('/'); expdate = expdate.substr( 0, separatorindex ) + '/1' + expdate.substr( separatorindex ); homecoming date.parse(startdate) <= date.parse(expdate); }, "must valid expiry date" ); $(function() { $( "#form" ).validate({ rules: { field_4: { required: true, future: true, minlength: 7 },

one way:

function (value, element) { var today = new date(); var thisyear = today.getfullyear(); var expmonth = +value.substr(0, 2); var expyear = +value.substr(3, 4); homecoming (expmonth >= 1 && expmonth <= 12 && (expyear >= thisyear && expyear < thisyear + 20) && (expyear == thisyear ? expmonth >= (today.getmonth() + 1) : true)) }

jquery jquery-validate future credit-card

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -