I’m using a dhtmlxcombo and want to validate so that it only allows input of numeric characters i.e. no letters or other symbols allowed.
So far I have the following…
It displays an alert boy if you type a numeric character, but does not actually stop the non-numeric character from being entered. Please advise on how I can actually prevent the non-numeric character from being typed into the dhtmlxcombo box.
function checkNumbersOnly(val) {
if (val < 48 || val > 57 ){
alert(‘PLEASE NOTE: You can only type numbers in this field’);
}
}
z1.attachEvent(“onKeyPressed”,onKeyPressedFunc);
function onKeyPressedFunc(kp){
checkNumbersOnly(kp);
};
Many thanks,
Graham.
function checkNumbersOnly(val) {
if (val < 48 || val > 57 ){
alert(‘PLEASE NOTE: You can only type numbers in this field’);
z1.setComboText(z1.getComboText().toString().replace(/[^0-9]+/g,""))
}
}