HTML:
<ul>
<li>
<span>到达</span>
<img class="date-s" src="/public/test/img/date0.png" alt="" onclick="$('#date').focus();"
data-field="datetime"/>
<ul>
<li class="time-s" data-date="start">9:00</li>
<li class="time-e" data-date="start">2016.12.7</li>
</ul>
</li>
<li>
<span>出发</span>
<img class="date-e" src="/public/test/img/date0.png" alt="" onclick="$('#date').focus();"
data-field="datetime"/>
<ul>
<li class="time-s" data-date="end">21:00</li>
<li class="time-e" data-date="end">2016.12.7</li>
</ul>
</li>
</ul>
JQery:
$('[name="desc"]').focus(function(){
var s1= $(' ul li:first-child ul li:first-child').text();
var s2=$(' ul li:last-child ul li:first-child').text();
var a1=$(' ul li:first-child ul li:last-child').text();
var start=new Date(a1.replace("-", "/").replace("-", "/"));
var a2=$(' ul li:last-child ul li:last-child').text();
var end=new Date(a2.replace("-", "/").replace("-", "/"));
if(start>end){
alert("日期选择有误");
return false;
}
if((a1==a2)&&(s1>s2)){
alert("时间选择有误");
return false;
}
});
版权声明:除特别声明外,本站所有文章皆是本站原创,转载请以超链接形式注明出处!