-1

hey am new so i dont have any idea how to validate isbn in html input type=""text" for both 13 and 10 digit isbn pls help me ...

Blockquote

<input type="text" id="name" name="name" class="col-xs-12 col-sm-5" pattren="??" />
davejagoda
  • 2,420
  • 1
  • 20
  • 27
Adi King
  • 25
  • 1
  • 9

1 Answers1

0

You probably can't do this with regex alone since the last digit is a calculated checksum, but here's a good resource to get you headed in the right direction and invalidate some obvious cases. There's information on how the checksum is calculated there and also on Wikipedia.

ISBN-10 example regex:

^(?:ISBN(?:-10)?:?\)?(?=[0-9X]{10}$|(?=(?:[0-9]+[-\]){3})[-\0-9X]{13}$)[0-9]{1,5}[-\]?[0-9]+[-\]?[0-9]+[-\]?[0-9X]$

ISBN-13 example regex:

^(?:ISBN(?:-13)?:?\)?(?=[0-9]{13}$|(?=(?:[0-9]+[-\]){4})[-\0-9]{17}$)97[89][-\]?[0-9]{1,5}[-\]?[0-9]+[-\]?[0-9]+[-\]?[0-9]$
joeyc
  • 55
  • 1
  • 6