Jojoxx.net logotyp

 

 

Användare ikonAnvändare
Besökare just nu: 73
Snabblänkar ikonSnabblänkar
JavaScript-arkivet
Perl
FAQ

Sök på Jojoxx.net


Kontrollera organisationsnummer

Exempel

Organisationsnummer:

Kod


<script type="text/javascript">
/*  The code contained in this  file is copyrighted by www.jojoxx.net
The file may be used for none commercial applications and distributed
as long as these lines remain intact.  The file or part of it may not
be sold  or  included  in any  other commercial  application  without
agreement from the author. If you have questions or comments, contact
the author at http://www.jojoxx.net

© Copyright - www.jojoxx.net - 2004                                */

function organisationsnummer(nr){
	this.valid=false;
	if(!nr.match(/^(\d{1})(\d{5})\-(\d{4})$/)){ return false; }
	this.group=RegExp.$1;
	this.controldigits=RegExp.$3;
	this.alldigits=this.group+RegExp.$2+this.controldigits;
	if(this.alldigits.substring(2,3)<2){ return false }
	var nn="";
	for(var n=0;n<this.alldigits.length;n++){ nn+=((((n+1)%2)+1)*this.alldigits.substring(n,n+1)); }
	this.checksum=0;
	for(var n=0;n<nn.length;n++){ this.checksum+=nn.substring(n,n+1)*1; }
	this.valid=(this.checksum%10==0)?true:false;
}
</script>

<form onsubmit="if(new organisationsnummer(this.pnr.value).valid){ alert('Giltigt organisationsnummer'); } else { alert('0giltigt organisationsnummer'); }; return false;">
Organisationsnummer: <input type="text" name="pnr"> <input type="submit" value="Kontrollera">
</form>

Kommentar

Scriptet kontrollerar att ett organisationsnummerär korrekt ifyllt.

,