나는 JQuery와 날짜 선택기를 사용하고 있는데에서 날짜와 날짜가 난유효성 검사 날짜
에 날짜보다 작아야에서 날짜와 같은 유효 할 경우 나는 날짜를 확인하고 싶습니다 당신이 jQuery를 DatePicker에서를 사용하여 갈 계획으로 여기
http://jqueryui.com/datepicker/#date-range
나는 JQuery와 날짜 선택기를 사용하고 있는데에서 날짜와 날짜가 난유효성 검사 날짜
에 날짜보다 작아야에서 날짜와 같은 유효 할 경우 나는 날짜를 확인하고 싶습니다 당신이 jQuery를 DatePicker에서를 사용하여 갈 계획으로 여기
http://jqueryui.com/datepicker/#date-range
찾을 수있는 JQuery와 날짜 선택 코드를 사용하여, 시작과 종료 날짜의 요구 사항에 따라이 텍스트 상자를 구현하시기 바랍니다.
다음 제출에 당신이 자바 스크립트에서 날짜 대해서 typeof() 값을 반환합니다
var startDate = $(".selector").datepicker("getDate");
GETDATE() 메소드를 통해 날짜를 선택할 수 있습니다.
이제 조건부 접근 방식을 사용하여 날짜를 비교할 수 있습니다.
데모 예 :
가 포함 JS 파일
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
HTML
Start date: <input type="text" id="txtStartDate">
End date: <input type="text" id="txtEndDate">
<input id="btnValidateDate" type="button" value="Validate Dates" />
jQuery를
$(function(){
$("#txtStartDate").datepicker();
$("#txtEndDate").datepicker();
$('#btnValidateDate').click(function(){
var startDate = $("#txtStartDate").datepicker("getDate");
var endDate = $("#txtEndDate").datepicker("getDate");
if(startDate > endDate)
alert('Invalid date! End date should be greater than start date.');
else
alert('Valid date');
});
});
이 부분은 fiddle demo입니다.
대단히 감사합니다. – hikki
싫어요. demo':)'http://stackoverflow.com/questions/10931288/how-to-add-subtract-dates-with-javascript/10931362#10931362; 데모 나 바이올린 녀석있어? –