You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

This is a quick script for comparing two dates and ensuring that one is larger than the other.

Type the following script in the Custom HTML element in your form and amend the form field name accordingly. Our example below shows a reading from the fields "start_date" and "end_date".

นี่เป็นสคริปต์ด่วนสำหรับเปรียบเทียบสองวันที่และตรวจสอบให้แน่ใจว่ามีขนาดใหญ่กว่าอีกวัน

พิมพ์สคริปต์ต่อไปนี้ในองค์ประกอบ HTML ที่กำหนดเองในแบบฟอร์มของคุณและแก้ไขชื่อฟิลด์แบบฟอร์มตามลำดับ ตัวอย่างของเราด้านล่างแสดงการอ่านจากฟิลด์ "start_date" และ "end_date"

<script type="text/javascript">
$('form').submit(function(){
	startDate = $("input[name='start_date']").val();
	endDate = $("input[name='end_date']").val();
	if( endDate < startDate ){
		alert("End Date must be larger than the Start Date. Please try again.");
        $.unblockUI();
		return false;
	}else{
		return true;
	}
});

</script>
  • No labels