www.webdeveloper.com
Results 1 to 9 of 9

Thread: [RESOLVED] Help!! Euro notes checksum Validation Problem!

  1. #1
    Join Date
    Apr 2011
    Posts
    9

    resolved [RESOLVED] Help!! Euro notes checksum Validation Problem!

    Hello,
    I 'm working on Euro banknote validation, where I'm using authentication of the serial number of Euro banknotes by the calculation of the "checksum". Basically what this algorithm does is to replace the first letter of the serial number by a number (each letter represents where the banknote is originally from), then it calculates the sum of all digits. If the remaining of the division of that sum by 9 is 0 then your note is valid.

    More info:http://en.wikipedia.org/wiki/Euro_banknotes#Checksum.

    Some test data
    EURO Serial Number
    V44671133335
    T27620110932
    A00000000007

    The last serial number "A00000000007" works properly. but the first two for some reason don't work properly.

    Those are my javascript codes:
    Code:
    <html>
    <body>
    <script type="text/javascript">
    		
    var EBNSArray = new Array ("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "65", "66", "67", "68", "69", "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "90");
    
    function validation() 
    { 
        var i; 
    	var EBNS = document.forms["ebnsform"]["EBNS"].value; 
    
    	if (EBNS.length != 11 && EBNS.length != 12)
    	{
    	     alert ("Incorrect EBNS, please enter the correct EBNS"); 
    	     return false; 
    	}
    
    	if (EBNS.length == 11)
    	{
    		var letter_real = EBNS.charAt(0); 
    	}	
    	
    	if (EBNS.length == 12)
    	{
    		var letter_real = EBNS.charAt(1); 
    	}	
    	
        var letter_enter = EBNS.substring(1,11); 
        
    	var checkLetter = letter_enter % 9
    	
        if (letter_real == EBNSArray[checkLetter]) 
        {  
    	alert ("Correct EBNS");
            return true; 		 
        } 
        else 
        { 
    	alert ("Incorrect EBNS, please enter the correct EBNS");			
            return false; 
        }          
    } 
    </script>
    <form id="ebnsform">
    <P>Euro Banknote Number: <input type="text" id="EBNS" /><br /></form></center>
    <input type="button" onclick="validation()" value="Validation"/></p>
    </body>
    </html>

  2. #2
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,356

    Exclamation

    What alphabet are you using for the banknote letter verification? There seem to be more than 26 elements in the EBNSArray.

    The following won't work...
    Code:
        var letter_enter = EBNS.substring(1,11); 
        var checkLetter = letter_enter % 9
    ...because the letter_enter is a string and the modulo character "%" works on numbers.

    Also, where does our checksum total calculation occur?

    I'm suprised you even got one calculation to work correctly!

  3. #3
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Code:
    function validation() 
    { 
        var i; 
    	var EBNS = document.forms["ebnsform"]["EBNS"].value.toUpperCase(); 
    
    	if (EBNS.length != 11 && EBNS.length != 12)
    	{
    	     alert ("Incorrect EBNS, please enter the correct EBNS"); 
    	     return false; 
    	}
    
    	var numericEBNS = EBNS.replace(EBNS.charAt(0), EBNS.charCodeAt(0)); 
    	
    	var mod = numericEBNS &#37; 9
    	
        if (!mod) 
        {  
    	alert ("Correct EBNS");
            return true; 		 
        } 
        else 
        { 
    	alert ("Incorrect EBNS, please enter the correct EBNS");			
            return false; 
        }          
    }
    Where did you see the number of digits can be 11? AFAIK it is always 12
    At least 98% of internet users' DNA is identical to that of chimpanzees

  4. #4
    Join Date
    Apr 2011
    Posts
    9
    Hi JMRKER
    I'm using 26 alphabetic letter that are represented as numbers in the position of the ASCII table.
    Code:
    "65", "66", "67", "68", "69", "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "90"
    Also you have mentioned about "where does our checksum total calculation occur?"

    Code:
       var letter_enter = EBNS.substring(1,11); 
                 var checkLetter = letter_enter % 9
    but I don't know how to sort it out... please, could you be so kind to help me?

  5. #5
    Join Date
    Apr 2011
    Posts
    9

    Thanks

    Hi Fang,
    I really appreciate your help. Thank you so much, now it is working properly!

  6. #6
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Where did you see the number of digits can be 11? AFAIK it is always 12
    At least 98% of internet users' DNA is identical to that of chimpanzees

  7. #7
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,356

    Talking

    Quote Originally Posted by Fang View Post
    Where did you see the number of digits can be 11? AFAIK it is always 12
    OP appears to be counting the 1st letter as a number. Why ???

    Also, his ESNBArray has 36 elements rather than the 26 supposedly in the english alphabet. Why ???

    But if he's happy, let it be!

  8. #8
    Join Date
    Dec 2002
    Location
    Manchester, UK
    Posts
    6,276
    Quote Originally Posted by JMRKER View Post
    Also, his ESNBArray has 36 elements rather than the 26 supposedly in the english alphabet. Why ???
    Numbers.
    Every fight is a food fight when you’re a cannibal.

  9. #9
    Join Date
    Oct 2013
    Posts
    1

    The algorithm should be expanded

    The algorithm should be expanded to take into account that the second character from the left can be digit or letter.
    Valid Euro note number is VA0436214792

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles