Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trunk 3972 Invalid date message is display #571

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions webapp/src/main/webapp/WEB-INF/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ error.reportObject.type.required=Invalid type
error.reportObject.subType.required=Invalid subtype
error.date.future=Cannot be a date in the future
error.date.nonsensical=Nonsensical date, please check.
error.date.wrong=Invalid date
error.deathdate.before.birthdate=Death date must be after birth date
error.programWorkflow=Invalid Program Workflow
error.programWorkflowState=Invalid Program Workflow State
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,19 @@
input.parentNode.className = "listItemChecked";
}

function checkDate(input){
var dayfield=input.value.split("/")[0]
var monthfield=input.value.split("/")[1]
var yearfield=input.value.split("/")[2]
var dayobj = new Date(yearfield, monthfield-1, dayfield)
if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield))
{
document.getElementById("message").style.display = 'inline';
document.getElementById("message").innerHTML='<openmrs:message code="error.date.wrong"/>';
input.select();
}
}

// age function borrowed from http://anotherdan.com/2006/02/simple-javascript-age-function/
function getAge(d, now) {
var age = -1;
Expand Down Expand Up @@ -216,6 +229,15 @@
.lastCell {
border-bottom: 1px lightgray solid;
}
.msg{
border: 1px dashed darkred;
background-color: lightpink;
padding: 1px 6px 1px 6px;
margin-left: 4px;
margin-right: 4px;
vertical-align: middle;
}

</style>

<openmrs:globalProperty key="use_patient_attribute.mothersName" defaultValue="false" var="showMothersName"/>
Expand Down Expand Up @@ -407,10 +429,11 @@
<input type="text"
name="${status.expression}" size="10" id="birthdate"
value="${status.value}"
onChange="updateAge(); updateEstimated(this);"
onChange="updateAge(); updateEstimated(this);checkDate(this);"
onfocus="showCalendar(this,60)" />
<c:if test="${status.errorMessage != ''}"><span class="error">${status.errorMessage}</span></c:if>
</spring:bind>
<span class="msg" id="message" style="display:none" ></span>

<span id="birthdateEstimatedCheckbox" class="listItemChecked" style="padding: 5px;">
<spring:bind path="patient.birthdateEstimated">
Expand Down