In this Pen I'll show you simple algorithm to check if NIP (Polish Tax Number) is correct or not.
A Pen by Paweł Mansfeld on CodePen.
<form id="form"> | |
<input type="text" name="nip" id="nip" placeholder="NIP" required> | |
<input type="reset" name="reset" value="Reset" class="wyslij" style="background-color:#fff;"><input type="submit" name="submit" value="Wyślij" class="wyslij" style="background-color:#fff;"> | |
</form> |
In this Pen I'll show you simple algorithm to check if NIP (Polish Tax Number) is correct or not.
A Pen by Paweł Mansfeld on CodePen.
$("#nip").change(function(){ | |
var currentnip = $("#nip").val().replace(/\D/g,""); | |
$(this).val(currentnip); | |
}); | |
$("#form").submit(function(){ | |
var nip = $("#nip").val(); | |
var nipsum = parseInt(nip.charAt(0))*6+parseInt(nip.charAt(1))*5+parseInt(nip.charAt(2))*7+parseInt(nip.charAt(3))*2+parseInt(nip.charAt(4))*3+parseInt(nip.charAt(5))*4+parseInt(nip.charAt(6))*5+parseInt(nip.charAt(7))*6+parseInt(nip.charAt(8))*7; | |
reszta = nipsum % 11; | |
if(reszta == parseInt(nip.charAt(9))){ | |
alert("NIP poprawny!"); | |
} | |
else{ | |
alert("NIP niepoprawny"); | |
} | |
}); |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> |