Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

This is a quick script on how to can compare 2 for comparing two dates and ensures ensuring that one is larger than the other. Please put this

Type the following script in a the Custom HTML element in your form . Remember to enclose this coding in the <script type="text/javascript"> blockand amend the form field name accordingly. Our example below shows a reading from the fields "start_date" and "end_date".

Code Block
langjavascript
<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.");
		return false;
	}else{
		return true;
	}
});

</script>