Html5 validate input value not eqaul to by default value
NickName:Muhammad Shahzad Ask DateTime:2015-03-30T16:06:16

Html5 validate input value not eqaul to by default value

I want to validate input value not equal to by default value through html5 validation,is it possible?

 <input type="text" name="First Name" value="First Name" id="FirstName"
 required=""  title="First Name is Required!" >

when user click on submit button, if input filed has value= First Name then show error.

I don't want to use placeholder="First Name".

Is there a way to validate using pattern attribute, like pattern="!First Name" <-Stupid logic :)

Copyright Notice:Content Author:「Muhammad Shahzad」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/29341205/html5-validate-input-value-not-eqaul-to-by-default-value

Answers
Franklin Satler 2015-09-26T00:47:58

Adding a pattern should work.\n\n<input type=\"text\" name=\"First Name\" value=\"First Name\" id=\"FirstName\"\n required=\"\" title=\"First Name is Required!\" pattern=\"^((?!First Name).)*$\">\n\n\nThis will throw a error if your value contains the string \"First Name\".",


Muhammad Bilal 2015-03-30T08:15:39

You can use Javascript for this try below:\n\n\r\n\r\n<form>\r\n <input type=\"text\" name=\"First Name\" value=\"First Name\" id=\"FirstName\" required=\"\" title=\"First Name is Required!\">\r\n <input type=\"submit\" value=\"Submit\" onclick=\"if (document.getElementById('FirstName').value == 'First Name') return false;\">\r\n</form>",


More about “Html5 validate input value not eqaul to by default value” related questions

Html5 validate input value not eqaul to by default value

I want to validate input value not equal to by default value through html5 validation,is it possible? &lt;input type="text" name="First Name" value="First Name" id="FirstName" required=""

Show Detail

Jquery Validate - How validate input with default value

I'm using Jquery Validate, as follows: &lt;input type="text" class="form-control" id="count_1" name="count_1" value="0011"&gt; The input field has a default value (value = &

Show Detail

What is the maximum and minimum value that will validate for a HTML5 input type=number using android webkit?

What is the maximum and minimum value that will validate for a HTML5 input type=number using android webkit ? &lt;input id="number" name="number" type="number" value="3.4028e+38" /&gt;

Show Detail

Angular 5 - Validate input field with default value

I have form with input field with default value. I want to add validation for that field to have exactly 5 characters. &lt;td&gt; &lt;input type="text" maxlength="5" ngModel #number="ngMo...

Show Detail

jQuery Validate plugin and a default input value not working

I have a form which has default values set, which should be treated as "empty fields". I did see another post on this subject, but have not been able to get anything to work so far. It still only t...

Show Detail

Parsley validate if default value are not update

I have created a form with around 18 input fields. All the input fields contain 0 as the default value. I need to validate and prevent form submission and need to show an alert message if at least ...

Show Detail

Default value for Html5 input attributes like min , max ,size etc

what is or where can i get the default value for Html5 input attributes if the attribute is not set Say for example &lt;input type="number"/&gt; what is the max and min value that is acceptabl...

Show Detail

HTML5, how to force input pattern validation on value change?

I am trying to learn HTML5 and came across the following. I would like to use the pattern input keyword to validate the input as the user types it (e.g. validation after pressing tab or changing fo...

Show Detail

HTML5 Input datetime-local default value of today and current time

Is there anyway that I can make a default value of HTML5 input type='datetime-local' to today's date and this current time. Thanks before

Show Detail

Validate 0.5 as Step Value in HTML5 Number Input

I want to have an input field which only allows to type whole numbers or .5 decimal numbers. e.g. 0, 0.5, 1, 1.5, 2, 2.5.......etc etc I am trying to do this with a HTML5 input field as so &lt;in...

Show Detail