Questions tagged [validation]

Validation is used to check data to make sure it fits whatever required specifications are set for it. Typically Validation is used in checking input data, and in verifying data before storage.

Data validation is the process of ensuring that a program operates on clean, correct and useful data. It applies rules or constraints to check for correctness, meaningfulness, and security of data that are input to the system.

The most common reasons for validation are to avoid entering data which violates a database schema, and to prevent unauthorized exploitation of a user interface.

Different kinds of validation

In evaluating the basics of data validation, generalizations can be made regarding the different types of validation, according to the scope, complexity, and purpose of the various validation operations to be carried out.

For example:

  1. Data type validation;
  2. Range and constraint validation;
  3. Code and Cross-reference validation; and
  4. Structured validation

Resources:

62584 questions
4865
votes
99 answers

How to validate an email address in JavaScript

Is there a regular expression to validate an email address in JavaScript?
pix0r
  • 30,601
  • 18
  • 82
  • 102
3567
votes
79 answers

How to validate an email address using a regular expression?

Over the years I have slowly developed a regular expression that validates MOST email addresses correctly, assuming they don't use an IP address as the server part. I use it in several PHP programs, and it works most of the time. However, from time…
acrosman
  • 12,375
  • 10
  • 36
  • 54
2458
votes
49 answers

Validate decimal numbers in JavaScript - IsNumeric()

What's the cleanest, most effective way to validate decimal numbers in JavaScript? Bonus points for: Clarity. Solution should be clean and simple. Cross-platform. Test cases: 01. IsNumeric('-1') => true 02. IsNumeric('-1.5') => true 03.…
Michael Haren
  • 97,268
  • 39
  • 159
  • 200
1516
votes
45 answers

A potentially dangerous Request.Form value was detected from the client

Every time a user posts something containing < or > in a page in my web application, I get this exception thrown. I don't want to go into the discussion about the smartness of throwing an exception or crashing an entire web application because…
Radu094
  • 26,658
  • 16
  • 56
  • 77
1448
votes
38 answers

(Built-in) way in JavaScript to check if a string is a valid number

I'm hoping there's something in the same conceptual space as the old VB6 IsNumeric() function?
Electrons_Ahoy
  • 30,983
  • 34
  • 101
  • 126
1138
votes
13 answers

How does the SQL injection from the "Bobby Tables" XKCD comic work?

Just looking at: (Source: https://xkcd.com/327/) What does this SQL do: Robert'); DROP TABLE STUDENTS; -- I know both ' and -- are for comments, but doesn't the word DROP get commented as well since it is part of the same line?
Blankman
  • 236,778
  • 296
  • 715
  • 1,125
1072
votes
8 answers

What is the maximum length of a valid email address?

What is the maximum length of a valid email address? Is it defined by any standard?
volatilevoid
  • 11,255
  • 4
  • 19
  • 16
969
votes
42 answers

How to validate phone numbers using regex

I'm trying to put together a comprehensive regex to validate phone numbers. Ideally it would handle international formats, but it must handle US formats, including the following: 1-234-567-8901 1-234-567-8901 x1234 1-234-567-8901 ext1234 1 (234)…
Nicholas Trandem
  • 2,795
  • 5
  • 28
  • 32
930
votes
68 answers

How to allow only numeric (0-9) in HTML inputbox using jQuery?

I am creating a web page where I have an input text field in which I want to allow only numeric characters like (0,1,2,3,4,5...9) 0-9. How can I do this using jQuery?
Prashant
  • 25,398
  • 62
  • 159
  • 219
770
votes
36 answers

An invalid form control with name='' is not focusable

In Google Chrome some customers are not able to proceed to my payment page. When trying to submit a form I get this error: An invalid form control with name='' is not focusable. This is from the JavaScript console. I read that the problem could be…
mp1990
  • 8,101
  • 3
  • 11
  • 16
555
votes
10 answers

Which characters make a URL invalid?

Which characters make a URL invalid? Are these valid URLs? example.com/file[/].html http://example.com/file[/].html
good
  • 5,581
  • 3
  • 14
  • 5
518
votes
19 answers

Check if inputs are empty using jQuery

I have a form that I would like all fields to be filled in. If a field is clicked into and then not filled out, I would like to display a red background. Here is my code: $('#apply-form input').blur(function () { if ($('input:text').is(":empty"))…
Keith Donegan
  • 24,863
  • 31
  • 89
  • 127
442
votes
10 answers

Disable validation of HTML5 form elements

In my forms, I'd like to use the new HTML5 form types, for example (more info about the types here). The problem is that Chrome wants to be super helpful and validate these elements for me, except that it sucks at it. If it…
nickf
  • 499,078
  • 194
  • 614
  • 709
418
votes
7 answers

What's an appropriate HTTP status code to return by a REST API service for a validation failure?

I'm currently returning 401 Unauthorized whenever I encounter a validation failure in my Django/Piston based REST API application. Having had a look at the HTTP Status Code Registry I'm not convinced that this is an appropriate code for a validation…
michaeljoseph
  • 6,548
  • 5
  • 23
  • 26
375
votes
35 answers

Email validation using jQuery

I'm new to jQuery and was wondering how to use it to validate email addresses.
DuH
  • 3,767
  • 3
  • 14
  • 3
1
2 3
99 100