在Asp.Net中的ISBN NO(For Book)验证 [英] ISBN NO(For Book) Validation In Asp.Net

查看:69
本文介绍了在Asp.Net中的ISBN NO(For Book)验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是ISBN NO(FOR Book)正确验证(正则表达式验证)n asp.net。

作为例:-978-0-12-345678-9

978-0-12-345678-9

978-1-234-56789-7

9781234567897

978 1 234 56789 7

Plz帮帮我

先谢谢

解决方案

你无法正确查看ISBN正则表达式 - 该数字包含一个校验位,正确的验证应该验证。

因为这需要计算,你不能使用正则表达式进行验证 - 你需要使用代码。



您可以进行简单的验证,检查它是否具有正确的位数,并忽略空格/连字符,但这就是您可以做的所有事情。


< blockquote>正如格里夫所说,这不是办法。对于纯语法验证,请参阅以下内容: http://regexlib.com/Search.aspx?k=ISBN& ; AspxAutoDetectCookieSupport = 1 [ ^ ]



从理论上讲,由于计算只是一种符号操作,而且我们在regexp中有一些看法,我认为可以做到。但这将是一个表达的地狱:)也许我会尝试有时这样做。但在此之前,您需要使用 CustomValidator [ ^ ]。<可以在此处找到校验和计算逻辑: http:// en。 wikipedia.org/wiki/International_Standard_Book_Number [ ^ ]

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

解决方案

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.


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 :) 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[^]


这篇关于在Asp.Net中的ISBN NO(For Book)验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆