TRUNK-2280 - Refactor maximum length checking in the view layer

I've extracted the forceMaxLength javascript function from encouterTypeForm.jsp and visitTypeForm.jsp to openmrs.js.

In response to the ticket: https://tickets.openmrs.org/browse/TRUNK-2280#comment-196502

Thanks.