JSFiddle - React, Tailwind, and code Playground
HTML
<div>
<label>Generate Project ID *</label>
<span class="options">
<label for="agreement_no">No</label>
<input type="radio" class="required authorization" value="0" id="agreement_no" name="agreement">
<label for="agreement_yes">Yes</label>
<input type="radio" class="required authorization" value="1" id="agreement_yes" name="agreement">
</span>
</div>
<div class="description"> </div>
<div class="question">
<label for="authorization_timestamp">Project ID</label>
<input type="text" readonly="readonly" maxlength="100" class="authorization_timestamp required" name="authorization_timestamp" id="authorization_timestamp">
</div>
JavaScript
$('.authorization[id$="yes"]').on('change', function() {
var dateStr;
if ($(this).val() == 1) {
var now = new Date();
var month = now.getMonth() + 1;
var day = now.getDate();
var year = now.getFullYear();
var h = now.getHours();
var m = now.getMinutes();
var s = now.getSeconds();
month = month < 10 ? "0" + month : month;
day = day < 10 ? "0" + day : day;
h = h < 10 ? "0" + h : h;
m = m < 10 ? "0" + m : m;
s = s < 10 ? "0" + s : s;
dateStr = month + "/" + day + "/" + year + " " + h + ":" + m + ":" + s
}
$("#authorization_timestamp").val(dateStr);
});
$('.authorization[id$="no"]').on('change', function() {
var dateStr;
dateStr = "";
$("#authorization_timestamp").val(dateStr);
});