Remove Non Number Characters From Form Textbox

[Total: 0    Average: 0/5]

This examples shows how to set up a form text box that removes non number characters.

Body Code:

<form name=exf1 action="">
<input type=text name=t1 value=""><BR>
<input type=button value="CHECK" onclick="check()">
function check() {
  if (document.exf1.t1.value == "") document.exf1.t1.value = "0";
  var a = document.exf1.t1.value.split("");
  var b = "";
  for (var i in a)
    if (a[i].match(/d/))
    b += a[i];
  while (b.length>1 && b.charAt(0) == "0") b=b.substr(1,b.length);
  document.exf1.t1.value = b;

Times Viewed: 1

Leave a Reply

Your email address will not be published. Required fields are marked *