Javascript verify integer or float value from textbox

  
    
// vaild inter number function
1
function isInteger(obj, Name)
2 {
3 if ( obj.value == "" )
4 return true ;
5
6 var regu = / ^[-]{0,1}[0-9]{1,}$ / ;
7 if ( isNaN(obj.value) || ! regu.test(obj.value))
8 {
9 alert(Name + ' must be integral number! ' );
10 obj.focus();
11 return false ;
12 }
13
14 return true ;
15 }

  
    
1 // verify float number from textbox
2   function ChangeQTY(obj, Name)
3 {
4
5 if (obj.value != "" && isNaN(obj.value))
6 {
7 alert(Name + ' must be number! ' );
8 obj.focus();
9 return false ;
10 }
11 }

你可能感兴趣的:(JavaScript)