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:

67160 questions
2554
votes
53 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
  • 105,752
  • 40
  • 168
  • 205
1878
votes
53 answers

How can I 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
  • 36,743
  • 36
  • 104
  • 127
1585
votes
48 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
  • 28,068
  • 16
  • 63
  • 80
1219
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
  • 259,732
  • 324
  • 769
  • 1,199
1203
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
  • 12,605
  • 4
  • 21
  • 16
1053
votes
45 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,815
  • 5
  • 30
  • 32
980
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?
djmzfKnm
  • 26,679
  • 70
  • 166
  • 227
926
votes
45 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
  • 9,699
  • 3
  • 13
  • 17
745
votes
22 answers

Asking the user for input until they give a valid response

I am writing a program that accepts user input. #note: Python 2.7 users should use `raw_input`, the equivalent of 3.X's `input` age = int(input("Please enter your age: ")) if age >= 18: print("You are able to vote in the United States!") else: …
Kevin
  • 74,910
  • 12
  • 133
  • 166
658
votes
21 answers

Is there a minlength validation attribute in HTML?

It seems the minlength attribute for an field doesn't work. Is there any other attribute in HTML with the help of which I can set the minimal length of a value for fields?
emilan
  • 12,825
  • 11
  • 32
  • 37
628
votes
13 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
  • 6,311
  • 3
  • 16
  • 5
545
votes
22 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
  • 26,213
  • 34
  • 94
  • 129
490
votes
2 answers

Regex match one of two words

I have an input that can have only 2 values apple or banana. What regular expression can I use to ensure that either of the two words was submitted?
CyberJunkie
  • 21,596
  • 59
  • 148
  • 215
474
votes
10 answers

Disable validation of HTML form elements

In my forms, I'd like to use the new HTML 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 fails…
nickf
  • 537,072
  • 198
  • 649
  • 721
473
votes
24 answers

Check if a number has a decimal place/is a whole number

I am looking for an easy way in JavaScript to check if a number has a decimal place in it (in order to determine if it is an integer). For instance, 23 -> OK 5 -> OK 3.5 -> not OK 34.345 -> not OK if(number is integer) {...}
Björn
  • 12,587
  • 12
  • 51
  • 70
1
2 3
99 100