Comprobar si un valor es un número entero


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. esEntero: function(valor){
  2. if(!isNaN(valor)){
  3. for(var i = 0; i<valor.length;i++){
  4. if(valor.charCodeAt(i)<48 || valor.charCodeAt(i)>57)
  5. return false;
  6. }
  7. }else{
  8. return false;
  9. }
  10.  
  11. return true;
  12. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.