Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Graham on Nov 26, 2008 10:16
open dhtmlx forum
dhtmlxcombo decimal numeric validation

Thanks, except I'm validating for numbers with decimar places too.  What do I add to prevent it from automatically removing the decimal point every time I enter an illegal character (i.e. a letter)

Thanks,
Graham.

Answer posted by Support on Nov 27, 2008 02:47
Just add decimal point to regexp mask

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,""))
  } 
}

Answer posted by Support on Nov 27, 2008 02:48
or 
function checkNumbersOnly(val) { 
  if (val < 48 || val > 57 ){ 
  alert('PLEASE NOTE: You can only type numbers in this field'); 
  z1.setComboText(parseFloat(z1.getComboText()))
  } 
}