Bad Input type email, creating a text input - html

I am getting the error "Bad input type email,creating a text input".Here below are the question specifications and my code. I am not getting exactly what constraints I am missing out or going wrong.
Question Description:
When creating the code for your form, you must use the HTML5 tags that are appropriate to replicate the form and fulfill all the specifications listed.
Code the form with autocomplete active.
The Name field you create should have autofocus, placeholder text, and be required. Don't forget to select the appropriate type for this field as well as all the fields that follow.
The Telephone field should have placeholder text, a pattern to restrict entry, and be required. Pattern should be of the type [ Pattern: 1-234-567-8910 ]
The Email address field should have placeholder text and allow multiple entries. This field should also be required.
The Books field should have a data list. You can select the content you would like to list.The Quantity (Maximum 5) field should have a minimum value of 1 and a maximum value of 5.
Code:
<html>
<head>
<style>
h2{
color:blue;
}
h4{
color:light blue;
font-style:italic;
}
</style>
</head>
<body>
<h2>A Simple Form</h2>
<h4>Form Fundamentals</h4>
<form method="get" action="" autocomplete="on">
<fieldset>
<legend>Customer Info</legend>
Name: <input type="text" autofocus="on" required placeholder="Enter your name"><br>
Telephone: <input type="text" pattern="[0-9]{1}[0-9]{3}[0-9]{3}[0-9]{4}" placeholder="Pattern: 1-234-567-8910" required><br>
Email address: <input type="email" placeholder="Enter your email address" multiple="multiple" required/>
</fieldset>
<fieldset>
<legend>Books</legend>
<input list="books">
<datalist id="books">
<option>abc</option>
</datalist>
Quantity(Maximum 5):<input type="number" min="1" max="5">
</fieldset>
<input type="submit">
</form>
</body>

Maybe you get the error because of the forward slash (/) after the required in input tag of Gmail.

Related

how to fill fields of the webpage where autocomplete is off

I want to automatically fill the registration form fields on an HTML web page. The form has multiple input boxes. I want to define the value of fields and when the web page appears the fields fill automatically. Before, I used autofill extension for it. But, the autocomplete feature of fields has been off and HTML objects don't have names or ids. Also, they have the same class. Therefore, fields don't fill automatically. How I can fill fields on the webpage automatically?
for example, two input objects and some of codes have been defined as follow:
<input autocomplete="off" class="red" placeholder="" type="text">
<input autocomplete="off" class="red" placeholder="" type="text">
<div class="input-item" max-length="10" placeholder="ID" data-v-6b0449e1=""><label class="label"><i>*</i>ID:</label><input autocomplete="off" class="ltr green" max-length="10" placeholder="" type="text"><p class="errors"><ul></ul></p></div>
<div class="select-item" data-v-6b0449e1=""><label class="label"><i>*</i>Sex:</label><select><option hidden="" disabled="" value="">Select</option><option value="false">male</option><option value="true">female</option></select><p class="errors"><ul></ul></p></div>
If you're looking to fill the fields when the page loads, you can use JavaScript:
HTML
<form class="my-form">
<input type="text" id="input1" />
<input type="text" id="input2" />
<input type="text" id="input3" />
</form>
JavaScript
window.onload = function() {
document.getElementById("input1").value = "This is the first input";
document.getElementById("input2").value = "This is the second input";
document.getElementById("input3").value = "This is the third input";
}
All this does is just, when the page loads (window.onload), replaces the value of each of the specified input fields to whatever you set it to.

Html pattern regex allow numeric only

I have an input type for contact number:
<input type="number" name="usercontact" placeholder="Contact Number" pattern="[0-9]{8,20}" />
I already put the pattern [0-9]{8,20} and i assume it don't allow other characters
But somehow e, and . (dot) able to pass through, why so? How should i only allow numbers only?
Try this
<input
type="number"
name="username"
placeholder="Username"
pattern="[0-9]{1,15}"
id="username">
Input type number can accept e or E and floating point numbers , negative symbols.
Pattern can be used for the validation.You can check if the entered value is valid.
According to This the pattern attribute applies when the value of the type attribute is text, search, tel, url, email, or password, otherwise it is ignored.But this works in some browser.
$('#numericInput').on('change keyup', function(event) {
if ( event.target.validity.valid ) {
$('#errorMsg').text($(this).val());
} else {
$('#errorMsg').text('invalid');
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form method="post">
<input type="number" name="usercontact" placeholder="Contact Number" pattern="[0-9]{8,20}" id="numericInput" />
<p id="errorMsg"></p>
<button type="submit">submit</button>
</form>

HTML field formatting

I have a standard HTML form.
<form method="post" name="myemailform" action="form-to-email.php">
Enter Name: <input type="text" name="name">
Enter Email Address: <input type="text" name="email">
Enter Message: <textarea name="message"></textarea>
<input type="submit" value="Send Form">
</form>
The problem is that when a value is input that is larger than the field size, upon clicking away, the field skips back to the beginning of the field so the end is cut off.
Is there a way to get it so that the view of the field stays where the carat was?
This is a javascript problem (client side), not a PHP one (server side).
You need to do this:
<input type="text" name="name" size="10" onblur="if (this.length > 10) {this.dir = 'rtl';} else {this.dir = 'ltr';}">
just check what is the proper length to use in order to change the input direction
You can use the HTML attribute size.

How do I edit the HTML form elements when in CSS? Do I assign an id?

<form id="form">
Name: <input type="text" name="name"/></br>
Status Message: <input type="text" name="statusmessage"/><br/>
</form>
So, do I assign an id="name" within the brackets? And then in CSS, do I call it with #form name?
html:
<input type="text" name="name" id="id" class="class" />
css: (any of the following would style the element)
input [name=name]{}
#id{}
.class{}
or you could style all text input fields in the form with:
#form input[type=text]{}
If you are using CSS2 you can use <input type="text" name="name" id="name" /> and then write this CSS:
#name {
:
}
It will select the element with ID name. Remember that using additional address info is unnecessary since the ID is uniquely sufficient to select any single element.

HTML input field hint

I want to provide the user with a hint on what he needs to enter into my text field. However, when I set the value, it does not disappear once a user clicks on the text field. How can you make it disappear?
<form action="input_password.htm">
<p>Username:<br><input name="Username" value="Enter username.." type="text" size="20" maxlength="20"></p>
</form>
With a bit of JavaScript:
<input
value="Enter username..."
onfocus="if (this.value === 'Enter username...') this.value=''" ... />
HTML5 has a nice attribute for this, called placeholder:
<input placeholder="Enter username.." ... />
but this attribute is not supported in old browsers.
the best way to give a hint is placeholder like this:
<input.... placeholder="hint".../>
You'd need attach an onFocus event to the input field via Javascript:
<input type="text" onfocus="this.value=''" value="..." ... />
I think for your situation, the easy and simple for your html input , you can
probably add the attribute title
<input name="Username" value="Enter username.." type="text" size="20" maxlength="20" title="enter username">
With HTML5, you can now use the placeholder attribute like this:
<form action="demo_form.asp">
<input type="text" name="fname" placeholder="First name"><br>
<input type="text" name="lname" placeholder="Last name"><br>
<input type="submit" value="Submit">
</form>
http://www.w3schools.com/tags/att_input_placeholder.asp
I have the same problem, and I have add this code to my application and its work fine for me.
step -1 : added the jquery.placeholder.js plugin
step -2 :write the below code in your area.
$(function () {
$('input, textarea').placeholder();
});
And now I can see placeholders on the input boxes!
This is exactly what you want
$(document).tooltip({ selector: "[title]",
placement: "top",
trigger: "focus",
animation: false});
<form id="form">
<label for="myinput1">Browser tooltip appears on hover but disappears on clicking the input field. But this one persists while user is typing within the field</label>
<input id="myinput1" type="text" title="This tooltip persists" />
<input id="myinput2" type="text" title="This one also" />
</form>
[ref]
If you mean like a text in the background, I'd say you use a label with the input field and position it on the input using CSS, of course. With JS, you fade out the label when the input receives values and fade it in when the input is empty. In this way, it is not possible for the user to submit the description, whether by accident or intent.
If you don't insist on the hint being displayed inside the input field, a modern solution would use a label element with the for attribute referring to the id of the input field, like this:
<form action="input_password.htm">
<label for="username" title="This is your user name...">Username: </label><input id="username" name="Username" type="text" size="20" maxlength="20"></p>
</form>
If you click the label, the input field will get the input focus.
If you hover over the label, it will show a longer explanation.
Generally the label should describe well enough what the user has to enter (in the case of user name it should be very much obvious).
Define tooltip text
<input type="text" id="firstname" name="firstname" tooltipText="Type in your firstname in this box">
Initialize and configure the script
<script type="text/javascript">
var tooltipObj = new DHTMLgoodies_formTooltip();
tooltipObj.setTooltipPosition('right');
tooltipObj.setPageBgColor('#EEE');
tooltipObj.setCloseMessage('Exit');
tooltipObj.initFormFieldTooltip();
</script>