gokilavasan m

gokilavasan m

  • NA
  • 51
  • 37.1k

help regarding javascript

Jul 23 2012 6:16 AM
hi,

   i have one textbox validation in javascript.in that validation does not allow the alphabets.it only allows the numbers and dot.



function isNumericDot(ID,alertMsg,keyCode)
{

if((keyCode >= 48 && keyCode <= 57 || keyCode == 8 || keyCode==46 || keyCode==9 ||keyCode == 33 || keyCode == 34 || keyCode == 35 || keyCode == 36 || keyCode == 37 || keyCode == 38 ||
keyCode == 39 || keyCode == 40 || keyCode == 45 || keyCode == 190 || keyCode == 46 || keyCode == 110 ||(keyCode >= 96 && keyCode <= 105)) && isShift == false || keyCode == 13 || keyCode == 16 || keyCode == 20)
{

if(keyCode==16)
isShift = true;
return ((keyCode >= 48 && keyCode <= 57 || keyCode == 8 ||keyCode==46 || keyCode==9 ||keyCode == 33 || keyCode == 34 || keyCode == 35 || keyCode == 36 || keyCode == 37 || keyCode == 38 ||
keyCode == 39 || keyCode == 40 || keyCode == 45 || keyCode == 190 || keyCode == 46 || keyCode == 110 ||(keyCode >= 96 && keyCode <= 105)) && isShift == false || keyCode == 13 || keyCode == 16 || keyCode == 20);
}

else
{
isShift = false;
alert(" Please Enter Numbers and Dot Only");
document.getElementById(ID).value= document.getElementById(ID).value.substring(0, document.getElementById(ID).value.length-1);
return false;
}
}




but i need zero doesnot allowed at first. what can i do

Examples:allowed:     0.2,0.002
              NotAllowed: 0,asd,@,$,  ,



Answers (1)