javascript - how to alert if the cuit is valid or not? -


i have input id cuit , need validate input in argentina. found code want run alert or know if cuit valid or not.

how can this?

function validacuit(scuit) {     var amult = '5432765432';     var amult = amult.split('');      if (scuit && scuit.length == 11) {         acuit = scuit.split('');         var iresult = 0;         (i = 0; <= 9; i++) {             iresult += acuit[i] * amult[i];         }         iresult = (iresult % 11);         iresult = 11 - iresult;          if (iresult == 11) iresult = 0;         if (iresult == 10) iresult = 9;          if (iresult == acuit[10]) {             return true;         }     }     return false; } 

if dont true/false output ternary (?) operator friend:

alert( validacuit( "1234" ) ? "valid input!" : "wrong input!"); 

Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -