Click here to Skip to main content
11,502,559 members (38,109 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
what is ISBN NO(FOR Book)proper validation(Regular expression validation)n asp.net.
As Ex:-978-0-12-345678-9
978-0-12-345678-9
978-1-234-56789-7
9781234567897
978 1 234 56789 7
Plz Help me
Thanks In advance
Posted 26-Dec-12 6:57am
Comments
Sandeep Mewara at 26-Dec-12 13:16pm
   
have you tried to write a regular expression for it by yourself so far?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You can't properly check an ISBN with a regex - the number contains a check digit which a proper validation should verify.
Because this requires a calculation, you cannot verify it with a regex - you need to use code.

You can do a simple validation to check it has the right number of digits and ignore the spaces/hyphens but that's about all you can do.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

As Griff mentioned, it is not the way to do it. For pure syntactical validation, see these ones: http://regexlib.com/Search.aspx?k=ISBN&AspxAutoDetectCookieSupport=1[^]

In theory, since calculation is just a symbol manipulation, and we have look-around in regexp, I think it could be done. But it would be a hell of an expression Smile | :) Maybe I will try to do it sometimes. But until than you will need to use a CustomValidator[^].

The checksum calculation logic can be found here: http://en.wikipedia.org/wiki/International_Standard_Book_Number[^]
  Permalink  
v2

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



Advertise | Privacy | Mobile
Web03 | 2.8.150520.1 | Last Updated 26 Dec 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100