Same question asked and I have answered there -
I presume that customer input is the element you are talking about.
Javascript will return a message if no value has been added, maybe why it does not work in your sample as the java code was not copied over. With the required field, it will only show a small pop-up at the element that says required in Chrome, no messages at all.
<pre><button class="btn btn-primary" onclick="validateme();">Submit</button>
<pre><script type="text/javascript">
function validateme() {
var customer = document.getElementById('customer');
if (customer.length == 0 && customer.value == "") {
alert('No valid customer added.');
document.getElementById('customer').focus();
}
</script>