Click here to Skip to main content
Click here to Skip to main content

ISBN13 Validation

, 27 Mar 2007 CPOL
Rate this:
Please Sign up or sign in to vote.
Validating ISBN13 numbers on format and correct checksum in class or CustomValidator (ISBN: book reference numbers)
Example in ASP.NET and WinForms

Introduction

This is my first article and hopefully not the last. I was looking for a good and simple article to start with. I hope this is a good start and that you guys can use my code.

The function of this article is to explain the possibilities of the ISBN13 validation object I created. It validates a few different things specified by ISBN International. I will explain them in this article.

Background

The basic idea behind ISBN numbers is code standard for books. For those of you who want to know more about ISBN, here is some info from Wikipedia and ISBN International.

Related Articles

There is another article (ASP.NET ISBN Validator) on The Code Project about ISBN validation. However, there are a few differences.

This code:

  • is written in C#
  • has a separate ISBN13 validation class
  • validates on grouped and ungroup ISBN13 numbers
  • only validates ISBN13 numbers (this is the standard at the moment)

Using the Code

The code is very basic and straightforward. The library has a class ISBN.ISBN13. Here is an example code to show the use of the class. As you can see, the constructor has an overload to input the ISBN directly.

ISBN.ISBN13 isbnValid = new ISBN13();
isbnValid.ISBN = "978-0-571-08989-5";

ISBN.ISBN13 isbnValid2 = new ISBN13("978-0-571-08989-5");

Validation is done directly when the ISBN is set. You can see if it is valid with the IsValid property.

ISBN13 also has some static methods that are interesting. These are easy to use.

  • IsValidISBN(string isbn) : bool 
  • GetISBNFormat(string isbn) : ISBNGroupingFormat 
  • ValidateChecksum(string isbn) : bool 

To use the validator control, add the ToolboxItem. This way you can drag and drop the control. It is inherited from the CustomValidator control. The validation is done by the ISBN13 class.

You can also add this to use the ISBN validator in your ASP form.

    <%@ register assembly="ISBN" namespace="ISBN.Web" tagprefix="cc1" %> 
    <%cc1:isbn13validator controltovalidate="TextBox1" 
    runat="server" id="ISBN13Validator1"%> 
</cc1:isbn13validator%>

Points of Interest

One of the most interesting points to look at is the wild RegEx string used to validate the grouped ISBN. Is my first RegEx this long?

History

  • 27th March, 2007: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Matglas
Web Developer
Netherlands Netherlands
I started with classic ASP in 2000 after done a lot of HTML stuff. I wanted more dynamic things. Before that time I told a friend I would never start to program. To complicated. When I started to do it I was sold immediatly.
 
In about 2005 I started to build ASP.NET app's. Lately I liked to make .NET Forms more.

Comments and Discussions

 
QuestionError? PinmemberMember 153090917-Nov-09 5:41 
GeneralSimple code [modified] PinmemberNightCrawler03X23-Nov-08 2:07 
Questionyou do know about regular expression validator? Pinmemberbug menot27-Mar-07 10:05 
AnswerRe: you do know about regular expression validator? PinmemberThomas Weidenmueller27-Mar-07 11:34 
GeneralRe: you do know about regular expression validator? PinmemberMatglas27-Mar-07 21:22 
AnswerRe: you do know about regular expression validator? PinmemberMatglas27-Mar-07 23:42 
GeneralWhy make it more complicated than necessary Pinmemberednrgc27-Mar-07 9:40 
GeneralRe: Why make it more complicated than necessary [modified] PinmemberMatglas27-Mar-07 21:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.141223.1 | Last Updated 27 Mar 2007
Article Copyright 2007 by Matglas
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid