473,387 Members | 1,578 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Input Validation for UPC Numbers

Hello,

I have been searching and searching for a js function that can check
whether or not a UPC code that is entered is a valid format. I don't
expect the correct UPC code in relation to the actual product (although
we hope that is accurate), but at least check that the number entered
is in fact a valid UPC code, just like they do for credit cards. I need
this for UPC code from 8 to 13 digits in length. I found a couple
things but they didn't seem to work. They added a check digit which
didn't match the check digit on the UPC codes I got off an actual
product. Is there something out there that doesn't have to add a check
digit and that can just take the whole UPC number and check whether
it's valid or not?

Thanks,
KP

Feb 2 '06 #1
3 4203
Kermit Piper wrote:
Hello,

I have been searching and searching for a js function that can check
whether or not a UPC code that is entered is a valid format. I don't
expect the correct UPC code in relation to the actual product (although
we hope that is accurate), but at least check that the number entered
is in fact a valid UPC code, just like they do for credit cards. I need
this for UPC code from 8 to 13 digits in length. I found a couple
things but they didn't seem to work. They added a check digit which
didn't match the check digit on the UPC codes I got off an actual
product. Is there something out there that doesn't have to add a check
digit and that can just take the whole UPC number and check whether
it's valid or not?

Thanks,
KP

function looksLikeUPC(val){return /^\d{8,13}$/.test(val);}

Very rudimentary, though.
Mick

Feb 2 '06 #2
JRS: In article <11*********************@g43g2000cwa.googlegroups. com>,
dated Thu, 2 Feb 2006 00:11:13 remote, seen in
news:comp.lang.javascript, Kermit Piper <di***********@hotmail.com>
posted :
I have been searching and searching for a js function that can check
whether or not a UPC code that is entered is a valid format. I don't
expect the correct UPC code in relation to the actual product (although
we hope that is accurate), but at least check that the number entered
is in fact a valid UPC code, just like they do for credit cards. I need
this for UPC code from 8 to 13 digits in length. I found a couple
things but they didn't seem to work. They added a check digit which
didn't match the check digit on the UPC codes I got off an actual
product. Is there something out there that doesn't have to add a check
digit and that can just take the whole UPC number and check whether
it's valid or not?


Find us the specification for a UPC product code, and something could be
written.

General validation : <URL:http://www.merlyn.demon.co.uk/js-valid.htm>
ISBN validation : <URL:http://www.merlyn.demon.co.uk/js-misc0.htm>

For some systems, it's easiest to compute validity /en bloc/
For some systems, it's easiest to compute the check data needed for the
real data.
For some systems, both are easy.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Feb 2 '06 #3
On 2006-02-02, Kermit Piper <di***********@hotmail.com> wrote:
Hello,

I have been searching and searching for a js function that can check
whether or not a UPC code that is entered is a valid format. I don't
expect the correct UPC code in relation to the actual product (although
we hope that is accurate), but at least check that the number entered
is in fact a valid UPC code, just like they do for credit cards. I need
this for UPC code from 8 to 13 digits in length. I found a couple
things but they didn't seem to work. They added a check digit which
didn't match the check digit on the UPC codes I got off an actual
product. Is there something out there that doesn't have to add a check
digit and that can just take the whole UPC number and check whether
it's valid or not?


there's a way to calculate the check digit google for it you'll find it.

Bye.
Jasen
Feb 3 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Otto Krüse | last post by:
Hi everyone, I'm building a GUI in which I want, amongst other things, for people to fill in there postal code. The postal codes of my country (Holland) are in this format: 1234 AB So for the...
6
by: Boyd Reilly | last post by:
I have a form that has the user pick the type of question he will answer. The input field will be a text, numeric or date type. So, after the question is answered, I need to change the input...
3
by: tdmailbox | last post by:
What is the proper way to set up a validation rule to only allow numbers? I want to allow both 1024 and 1024.25
3
by: BerkshireGuy | last post by:
Is there a way to setup an input mask to be a range of numbers? For instance, only allowing 1,2,3,4 or just 1 or 2. Or should I just do a test in the BeforeUpdate event of the control? Thanks,...
1
by: John Slate | last post by:
I have built a simple form that uses input validation. I use the EnableClientScript option to produce a javascript alert box when input errors occur. The only validation is a password confirmation...
27
by: code_wrong | last post by:
Visual Basic (not dot net) what is the best way to check the User has entered an integer into an InputBox? isNumeric() checks for a numeric value .. but does not notify of numbers with decimal...
1
by: gordon | last post by:
Hello I am just starting off with C# after a long time out of programming. I am developing some test applications for pocket pcs that use the input to text boxes as the source for an equation....
3
by: louie310 | last post by:
I finally came up with an answer for creating a custom message if the input mask is violated. In the properties window for the phone field, open the data tab. In the validation rule I typed in the...
18
vikas251074
by: vikas251074 | last post by:
I am using ASP In my company, all employees have to sent materials out of premises. Any employee who need to sent material out will use this web application. In the first page, an employee enters...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.