dqdtgiw4736
dqdtgiw4736
2012-12-15 07:13

PHP验证比较开始和结束日期

  • php
  • validation

The below coding shows the comparison of start and end date and shows error if end date is greater than start date

But what I want to do is how to write the same functionality in full PHP code I don't know. Could anybody help to write the below functionality in PHP coding

HTML

<input type="text" id="starddate" />
<input type="text" id="enddate" />
<div id="msg"></div>
<input type="submit" id="submit" />

JQuery

jQuery.validator.addMethod("greaterThan", 
function(value, element, params) {

    if (!/Invalid|NaN/.test(new Date(value))) {
        return new Date(value) > new Date($(params).val());
    }

    return isNaN(value) && isNaN($(params).val()) 
        || (parseFloat(value) > parseFloat($(params).val())); 
},'Must be greater than {0}.');

$("#enddate").rules('add', { greaterThan: "#startdate" });
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答