Tuesday, May 18, 2010

JavaScript function to make text caps

1) Creating javascript file(util.js) and create function makeCaps()

/**
This function get the data on every key press and it will change that data into caps
*/
function makeCaps(data){
var val = data.value;
data.value = val.toUpperCase();

}

2) Include util.js file in jsp file

<script type='text/javascript' src="<%=request.getContextPath()%>/utils.js"></script>

3)Calling javascript function in jsp
<h:inputText id="tf_NAME" label="Name" autocomplete="off" onkeyup="makeCaps(this)">

No comments:

Post a Comment