I want to block backspace and delete button to remove $
and .
from the text box.
For example: if my text box value is $10.00 i should able to delete only the digits not the $ and dot.
<h:dataTable id="Dtable" var="item"
value="#{bean.list}">
<h:column>
<h:inputText id="txt1" value="#{item.Amount1}" onkeypress=" return isMoney(this,event)"></h:inputText>
</h:column>
</h:dataTable>
This is how i'm allowing only digits,$ and dot. to be entered in the text box.
function isMoney(thisObj,evt)
{
var charCode = (evt.which) ? evt.which : event.keyCode
if(charCode == 46 || charCode == 36) // decimal pt or $
return true;
if (charCode > 31 && (charCode < 48 || charCode > 57))
return false;
return true;
}
NOTE: No of rows may varry so I can't use id to get the particular textbox.