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

1. Registered User
Join Date
Apr 2011
Posts
9

## [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. 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. 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

4. Registered User
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. Registered User
Join Date
Apr 2011
Posts
9

## Thanks

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

6. Where did you see the number of digits can be 11? AFAIK it is always 12

7. Originally Posted by Fang
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. Originally Posted by JMRKER
Also, his ESNBArray has 36 elements rather than the 26 supposedly in the english alphabet. Why ???
Numbers.

9. Registered User
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
•

"

"

## X vBulletin 4.2.2 Debug Information

• Page Generation 0.15491 seconds
• Memory Usage 2,934KB
• Queries Executed 15 (?)
More Information
Template Usage (34):
• (1)SHOWTHREAD
• (1)ad_footer_end
• (1)ad_footer_start
• (1)ad_global_above_footer
• (1)ad_global_below_navbar
• (1)ad_global_header1
• (1)ad_global_header2
• (1)ad_navbar_below
• (1)ad_showthread_firstpost_sig
• (1)ad_showthread_firstpost_start
• (1)ad_thread_first_post_content
• (1)ad_thread_last_post_content
• (5)bbcode_code
• (2)bbcode_quote
• (1)footer
• (1)forumjump
• (1)forumrules
• (1)gobutton
• (1)header
• (1)headinclude
• (1)headinclude_bottom
• (9)memberaction_dropdown
• (1)navbar
• (4)navbar_link
• (1)navbar_moderation
• (1)navbar_noticebit
• (1)navbar_tabs
• (2)option
• (9)postbit
• (9)postbit_onlinestatus
• (9)postbit_wrapper
• (1)spacer_close
• (1)spacer_open
• (1)tagbit_wrapper

Phrase Groups Available (6):
• global
• inlinemod
• postbit
• posting
• reputationlevel
• showthread
Included Files (26):
• ./showthread.php
• ./global.php
• ./includes/class_bootstrap.php
• ./includes/init.php
• ./includes/class_core.php
• ./includes/config.php
• ./includes/functions.php
• ./includes/functions_navigation.php
• ./includes/class_friendly_url.php
• ./includes/class_hook.php
• ./includes/class_bootstrap_framework.php
• ./vb/vb.php
• ./vb/phrase.php
• ./includes/functions_facebook.php
• ./includes/functions_calendar.php
• ./includes/functions_bigthree.php
• ./includes/class_postbit.php
• ./includes/class_bbcode.php
• ./includes/functions_reputation.php
• ./includes/functions_notice.php
• ./packages/vbattach/attach.php
• ./vb/types.php
• ./vb/cache.php
• ./vb/cache/db.php
• ./vb/cache/observer/db.php
• ./vb/cache/observer.php

Hooks Called (72):
• init_startup
• friendlyurl_resolve_class
• init_startup_session_setup_start
• database_pre_fetch_array
• database_post_fetch_array
• init_startup_session_setup_complete
• global_bootstrap_init_start
• global_bootstrap_init_complete
• cache_permissions
• fetch_postinfo_query
• fetch_postinfo
• fetch_threadinfo_query
• fetch_threadinfo
• fetch_foruminfo
• load_show_variables
• load_forum_show_variables
• global_state_check
• global_bootstrap_complete
• global_start
• style_fetch
• global_setup_complete
• showthread_start
• showthread_getinfo
• strip_bbcode
• friendlyurl_clean_fragment
• friendlyurl_geturl
• forumjump
• cache_templates
• cache_templates_process
• template_register_var
• template_render_output
• fetch_template_start
• fetch_template_complete
• parse_templates
• fetch_musername
• notices_check_start
• notices_noticebit
• process_templates_complete
• friendlyurl_redirect_canonical
• showthread_post_start
• showthread_query_postids
• showthread_query
• bbcode_fetch_tags
• bbcode_create
• showthread_postbit_create
• postbit_factory
• postbit_display_start
• postbit_imicons
• bbcode_parse_start
• bbcode_parse_complete_precache
• bbcode_parse_complete
• postbit_display_complete
• memberaction_dropdown
• tag_fetchbit_complete
• forumrules
• navbits
• navbits_complete
• build_navigation_data
• build_navigation_array
• check_navigation_permission
• process_navigation_links_start
• process_navigation_links_complete
• set_navigation_menu_element
• build_navigation_menudata
• build_navigation_listdata
• build_navigation_list
• set_navigation_tab_main
• set_navigation_tab_fallback
• navigation_tab_complete
• fb_like_button
• showthread_complete
• page_templates