フォームを持っていますが、ステータス選択リストが変更された場合、ステータス有効日を必須フィールドにする必要があります。
function checkStatuses(){
$('.status').each(function (){
thisStatus = $(this).val().toLowerCase();
thisOrig_status = $(this).next('.orig_status').val().toLowerCase();
target = $(this).parents('td').nextAll('td:first').find('.datepicker');
if ( thisStatus == thisOrig_status )
{
target.val('');
}
else if( thisStatus == 'production' || thisStatus == 'production w/o appl')
{
target.val('<cfoutput>#dateformat(now(), "mm/dd/yyyy")#</cfoutput>').focus();
alert('The Status Effective Date is required.');
return false;
}
else
{
target.val('<cfoutput>#dateformat(now(), "mm/dd/yyyy")#</cfoutput>');
return false;
}
});
}
false を返すことで、フォームの送信が妨げられることはありません。上記のフォームは、次のような別の関数によって呼び出されています。
return checkStatuses();