aboutsummaryrefslogtreecommitdiff
path: root/files/el/learn/html
diff options
context:
space:
mode:
Diffstat (limited to 'files/el/learn/html')
-rw-r--r--files/el/learn/html/forms/index.html83
-rw-r--r--files/el/learn/html/forms/επικύρωση_δεδομένων_φόρμας/index.html869
-rw-r--r--files/el/learn/html/index.html58
3 files changed, 1010 insertions, 0 deletions
diff --git a/files/el/learn/html/forms/index.html b/files/el/learn/html/forms/index.html
new file mode 100644
index 0000000000..215164d6a6
--- /dev/null
+++ b/files/el/learn/html/forms/index.html
@@ -0,0 +1,83 @@
+---
+title: HTML forms
+slug: Learn/HTML/Forms
+tags:
+ - Beginner
+ - Featured
+ - Forms
+ - Guide
+ - HTML
+ - Landing
+ - Learn
+ - NeedsTranslation
+ - TopicStub
+ - Web
+translation_of: Learn/Forms
+---
+<div>{{LearnSidebar}}</div>
+
+<p class="summary">This module provides a series of articles that will help you master HTML forms. HTML forms are a very powerful tool for interacting with users; however, for historical and technical reasons, it's not always obvious how to use them to their full potential. In this guide, we'll cover all aspects of HTML forms, from structure to styling, from data handling to custom widgets.</p>
+
+<h2 id="Prerequisites">Prerequisites</h2>
+
+<p>Before starting this module, you should at least work through our <a href="/en-US/docs/Learn/HTML/Introduction_to_HTML">Introduction to HTML</a>. At this point you should find the {{anch("Basic guides")}} easy to understand, and also be able to make use of our <a href="/en-US/docs/Learn/HTML/Forms/The_native_form_widgets">Native form widgets</a> guide.</p>
+
+<p>The rest of the module however is a bit more advanced — it is easy to put form widgets on a page, but you can't actually do much with them without using some advanced form features, CSS, and JavaScript. Therefore, before you look at the other sections we'd recommend that you go away and learn some <a href="/en-US/docs/Learn/CSS">CSS</a> and <a href="/en-US/docs/Learn/JavaScript">JavaScript</a> first.</p>
+
+<div class="note">
+<p><strong>Note</strong>: If you are working on a computer/tablet/other device where you don't have the ability to create your own files, you could try out (most of) the code examples in an online coding program such as <a href="http://jsbin.com/">JSBin</a> or <a href="https://thimble.mozilla.org/">Thimble</a>.</p>
+</div>
+
+<h2 id="Basic_guides">Basic guides</h2>
+
+<dl>
+ <dt><a href="/en-US/docs/Learn/HTML/Forms/Your_first_HTML_form">Your first HTML form</a></dt>
+ <dd>The first article in our series provides your very first experience of creating an HTML form, including designing a simple form, implementing it using the right HTML elements, adding some very simple styling via CSS, and how data is sent to a server.</dd>
+ <dt><a href="/en-US/docs/Learn/HTML/Forms/How_to_structure_an_HTML_form">How to structure an HTML form</a></dt>
+ <dd>With the basics out of the way, we now look in more detail at the elements used to provide structure and meaning to the different parts of a form.</dd>
+</dl>
+
+<h2 id="What_form_widgets_are_available">What form widgets are available?</h2>
+
+<dl>
+ <dt><a href="/en-US/docs/Learn/HTML/Forms/The_native_form_widgets">The native form widgets</a></dt>
+ <dd>We now look at the functionality of the different form widgets in detail, looking at what options are available to collect different types of data.</dd>
+</dl>
+
+<h2 id="Validating_and_submitting_form_data">Validating and submitting form data</h2>
+
+<dl>
+ <dt><a href="/en-US/docs/Learn/HTML/Forms/Sending_and_retrieving_form_data">Sending form data</a></dt>
+ <dd>This article looks at what happens when a user submits a form — where does the data go, and how do we handle it when it gets there? We also look at some of the security concerns associated with sending form data.</dd>
+ <dt><a href="/en-US/docs/Learn/HTML/Forms/Form_validation">Form data validation</a></dt>
+ <dd>Sending data is not enough — we also need to make sure that the data users fill out in forms is in the correct format we need to process it successfully, and that it won't break our applications. We also want to help our users to fill out our forms correctly and don't get frustrated when trying to use our apps. Form validation helps us achieve these goals — this article tells you what you need to know.</dd>
+</dl>
+
+<h2 id="Advanced_guides">Advanced guides</h2>
+
+<dl>
+ <dt><a href="/en-US/docs/Learn/HTML/Forms/How_to_build_custom_form_widgets">How to build custom form widgets</a></dt>
+ <dd>You'll come across some cases where the native form widgets just don't provide what you need, e.g. because of styling or functionality. In such cases, you may need to build your own form widget out of raw HTML. This article explains how you'd do this and the considerations you need to be aware of when doing so, with a practical case study.</dd>
+ <dt><a href="/en-US/docs/Learn/HTML/Forms/Sending_forms_through_JavaScript">Sending forms through JavaScript</a></dt>
+ <dd>This article looks at ways to use a form to assemble an HTTP request and send it via custom JavaScript, rather than standard form submission. It also looks at why you'd want to do this, and the implications of doing so. (See also Using FormData objects.)</dd>
+ <dt><a href="/en-US/docs/Learn/HTML/Forms/HTML_forms_in_legacy_browsers">HTML forms in legacy browsers</a></dt>
+ <dd>Article covering feature detection, etc. This should be redirected to the cross browser testing module, as the same stuff is covered better there.</dd>
+</dl>
+
+<h2 id="Form_styling_guides">Form styling guides</h2>
+
+<dl>
+ <dt><a href="/en-US/docs/Learn/HTML/Forms/Styling_HTML_forms">Styling HTML forms</a></dt>
+ <dd>This article provides an introduction to styling forms with CSS, including all the basics you might need to know for basic styling tasks.</dd>
+ <dt><a href="/en-US/docs/Learn/HTML/Forms/Advanced_styling_for_HTML_forms">Advanced styling for HTML forms</a></dt>
+ <dd>Here we look at some more advanced form styling techniques that need to be used when trying to deal with some of the more difficult-to-style elements.</dd>
+ <dt><a href="/en-US/docs/Learn/HTML/Forms/Property_compatibility_table_for_form_widgets">Property compatibility table for form widgets</a></dt>
+ <dd>This last article provides a handy reference allowing you to look up what CSS properties are compatible with what form elements.</dd>
+</dl>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li><a href="/en-US/docs/Web/HTML/Element#Forms">HTML forms element reference</a></li>
+ <li><a href="/en-US/docs/Web/HTML/Element/input">HTML &lt;input&gt; types reference</a></li>
+</ul>
diff --git a/files/el/learn/html/forms/επικύρωση_δεδομένων_φόρμας/index.html b/files/el/learn/html/forms/επικύρωση_δεδομένων_φόρμας/index.html
new file mode 100644
index 0000000000..f4d9184454
--- /dev/null
+++ b/files/el/learn/html/forms/επικύρωση_δεδομένων_φόρμας/index.html
@@ -0,0 +1,869 @@
+---
+title: Επικύρωση δεδομένων φόρμας
+slug: Learn/HTML/Forms/Επικύρωση_δεδομένων_φόρμας
+translation_of: Learn/Forms/Form_validation
+---
+<div>{{LearnSidebar}}{{PreviousMenuNext("Learn/HTML/Forms/Sending_and_retrieving_form_data", "Learn/HTML/Forms/How_to_build_custom_form_widgets", "Learn/HTML/Forms")}}</div>
+
+<p class="summary">Η επικύρωση των δεδομένω σε φόρμα, εξασφαλίζει ότι οι χρήστες θα συμπληρώσουν τα πεδία της στην σωστή τους μορφή, ώστε να είνα ιβέβαιο πως τα δεδομένα που θα υποβληθούν θα είναι λειτουργήσουν με επιτυχία από τις άλλες εφαρμογές μας. Αυτό το άρθρο, θα διαπραγματευθεί όλα όσα πρέπει να γνωρίζετε σχετικά με την επικύρωση των δεδομένων.</p>
+
+<table class="learn-box standard-table">
+ <tbody>
+ <tr>
+ <th scope="row">Προαπαιτούμενα:</th>
+ <td>Γνώση όρων πληροφορικής, επαρκής κατανόηση των  τεχνολογιών <a href="/en-US/docs/Learn/HTML">HTML</a>, <a href="/en-US/docs/Learn/CSS">CSS</a>, και <a href="/en-US/docs/Learn/JavaScript">JavaScript</a>.</td>
+ </tr>
+ <tr>
+ <th scope="row">Σκοπός:</th>
+ <td>Η κατανόηση της σπουδαιότητας της επικύρωσης δεδομένων και πως γίνεται η εφαρμογή της.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Τι_είναι_η_επικύρωση_δεδομένων_φόρμας">Τι είναι η επικύρωση δεδομένων φόρμας;</h2>
+
+<p>Αν επισκεφτείτε οποιαδήποτε δημοφιλή ιστοσελίδα με φόρμα εγγραφής, θα διαπιστώσετε ότι σας ενημερώνει όταν δεν εισαγάγετε στη σωστή μορφή τα δεδομένα που απαιτεί. Σας ενημερώνει πως:</p>
+
+<ul>
+ <li>«Αυτό το πεδίο είναι υποχρεωτικό»  (δεν επιτρέπεται να μείνει κενό)</li>
+ <li>«Παρακαλώ εισάγετε τον τηλεφωνικό σας αριθμό στην μορφή xxx-xxxx" (υποχρεωτικά τρεις αριθμοί, μετά παύλα και μετά τέσσερις αριθμοί)</li>
+ <li>«Παρακαλώ εισάγετε μια έγκυρη ηλεκτρονική διεύθυνση» (αν η μορφή της διεύθυνσης δεν είναι της μορφής «κάποιος@παράδειγμα.com»)</li>
+ <li>«Ο κωδικός ασφαλείας πρέπει να είναι από 8 εως 30 χαρακτήρες, και να περιλαμβάνει κατ' ελάχιστον, ένα κεφαλαίο γράμμα, ένα σύμβολο και έναν αριθμό»</li>
+</ul>
+
+<p>Αυτό καλείται <strong>επικύρωση δεδομένων φόρμας</strong> — όταν εισάγονται δεδομένα, η εφαρμογή ελέγχει ότι τα δεδομένα είναι σωστά. Αν είναι σωστά, η εφαρμογή επιτρέπει τα δεδομένα να υποβληθούν στον εξυπηρετητή και (συνήθως) να αποθηκευτούν σε μια βάση δεδομένων. Αν δεν είναι σωστά τα δεδομένα, ενημερώνει με μήνυμα, εξηγώντας τις διορθώσεις που απαιτούνται. Η επικύρωση δεδομένων φόρμα μπορεί να εφαρμοστεί με διαφορετικούς τρόπους.</p>
+
+<p>Επιδίωξη είναι η εισαγωγή των δεδομένω να είναι όσο το δυνατόν ευκολότερη. Τότε γιατί επιμένουμε να επικυρώνουμε τα δεδομένα στις φόρμες; Για τους τρεις παρακάτω κυρίως λόγους:</p>
+
+<ul>
+ <li><strong>Θέλουμε τα σωστά δεδομένα, στην σωστή μορφή</strong>— οι εφαρμογές θα δυσλειτουργήσουν αν τα δεδομένα των χρηστών αποθηκευτούν σε λανθασμένη μορφή, αν δεν έχουν τις σωστές πληροφορίες ή αν έχουν παραλειφθεί πληροφορίες που απαιτούνται.</li>
+ <li><strong>We want to protect our users' accounts</strong> — by forcing our users to enter secure passwords, it makes it easier to protect their account information.</li>
+ <li><strong>We want to protect ourselves</strong> — there are many ways that malicious users can misuse unprotected forms to damage the application they are part of (see <a href="/en-US/docs/Learn/Server-side/First_steps/Website_security">Website security</a>).</li>
+</ul>
+
+<h3 id="Different_types_of_form_validation">Different types of form validation</h3>
+
+<p>There are two different types of form validation which you'll encounter on the web:</p>
+
+<ul>
+ <li><strong>Client-side validation</strong> is validation that occurs in the browser, before the data has been submitted to the server. This is more user-friendly than server-side validation as it gives an instant response. This can be further subdivided:
+
+ <ul>
+ <li><strong>JavaScript</strong> validation is coded using JavaScript. It is completely customizable.</li>
+ <li><strong>Built-in form validation</strong> using HTML5 form validation features.  This generally does not require JavaScript. Built-in form validation has better performance, but it is not as customizable as JavaScript.</li>
+ </ul>
+ </li>
+ <li><strong>Server-side validation</strong> is validation which occurs on the server, after the data has been submitted.  Server-side code is used to validate the data before it is saved into the database. If the data fails authentication, a response is sent back to the client to tell the user what corrections to make. Server-side validation is not as user-friendly as client-side validation, as it does not provide errors until the entire form has been submitted.  However, server-side validation is your application's last line of defense against incorrect or even malicious data. All popular <a href="/en-US/docs/Learn/Server-side/First_steps/Web_frameworks">server-side frameworks</a> have features for <strong>validating</strong> and <strong>sanitizing</strong> data (making it safe).</li>
+</ul>
+
+<p>In the real world, developers tend to use a combination of client-side and server-side validation.</p>
+
+<h2 id="Using_built-in_form_validation">Using built-in form validation</h2>
+
+<p>One of the features of <a href="/en-US/docs/HTML/HTML5">HTML5</a> is the ability to validate most user data without relying on scripts. This is done by using <a href="/en-US/docs/HTML/HTML5/Constraint_validation">validation attributes</a> on form elements, which allow you to specify rules for a form input like whether a value needs to be filled in, the minimum and maximum length of the data, whether it needs to be a number, an email address, or something else, and a pattern that it must match. If the entered data follows all those rules, it is considered valid; if not, it is considered invalid.</p>
+
+<p>When an element is valid:</p>
+
+<ul>
+ <li>The element matches the {{cssxref(":valid")}} CSS pseudo-class; this will let you apply a specific style to valid elements.</li>
+ <li>If the user tries to send the data, the browser will submit the form, provided there is nothing else stopping it from doing so (e.g., JavaScript).</li>
+</ul>
+
+<p>When an element is invalid:</p>
+
+<ul>
+ <li>The element matches the {{cssxref(":invalid")}} CSS pseudo-class; this will let you apply a specific style to invalid elements.</li>
+ <li>If the user tries to send the data, the browser will block the form and display an error message.</li>
+</ul>
+
+<h3 id="Validation_constraints_on_input_elements_—_starting_simple">Validation constraints on input elements — starting simple</h3>
+
+<p>In this section, we'll look at some of the different HTML5 features that can be used to validate {{HTMLElement("input")}} elements.</p>
+
+<p>Let's start with a simple example — an input that allows you to choose your favorite fruit out of a choice of banana or cherry. This involves a simple text {{HTMLElement("input")}} with a matching label, and a submit {{htmlelement("button")}}. You can find the source code on GitHub as <a href="https://github.com/mdn/learning-area/blob/master/html/forms/form-validation/fruit-start.html">fruit-start.html</a>, and a live example below:</p>
+
+<div class="hidden">
+<h6 id="Hidden_code">Hidden code</h6>
+
+<pre class="brush: html">&lt;form&gt;
+ &lt;label for="choose"&gt;Would you prefer a banana or cherry?&lt;/label&gt;
+ &lt;input id="choose" name="i_like"&gt;
+ &lt;button&gt;Submit&lt;/button&gt;
+&lt;/form&gt;</pre>
+
+<pre class="brush: css">input:invalid {
+ border: 2px dashed red;
+}
+
+input:valid {
+ border: 2px solid black;
+}</pre>
+</div>
+
+<p>{{EmbedLiveSample("Hidden_code", "100%", 50)}}</p>
+
+<p>To begin with, make a copy of <code>fruit-start.html</code> in a new directory on your hard drive.</p>
+
+<h3 id="The_required_attribute">The required attribute</h3>
+
+<p>The simplest HTML5 validation feature to use is the {{htmlattrxref("required", "input")}} attribute — if you want to make an input mandatory, you can mark the element using this attribute. When this attribute is set, the form won't submit (and will display an error message) when the input is empty (the input will also be considered invalid).</p>
+
+<p>Add a <code>required</code> attribute to your input, as shown below:</p>
+
+<pre class="brush: html">&lt;form&gt;
+ &lt;label for="choose"&gt;Would you prefer a banana or cherry?&lt;/label&gt;
+ &lt;input id="choose" name="i_like" required&gt;
+ &lt;button&gt;Submit&lt;/button&gt;
+&lt;/form&gt;</pre>
+
+<p>Also take note of the CSS included in the example file:</p>
+
+<pre class="brush: css">input:invalid {
+ border: 2px dashed red;
+}
+
+input:valid {
+ border: 2px solid black;
+}</pre>
+
+<p>This causes the input to have a bright red dashed border when it is invalid, and a more subtle black border when valid. Try out the new behaviour in the example below:</p>
+
+<p>{{EmbedLiveSample("The_required_attribute", "100%", 50)}}</p>
+
+<h3 id="Validating_against_a_regular_expression">Validating against a regular expression</h3>
+
+<p>Another very common validation feature is the {{htmlattrxref("pattern","input")}} attribute, which expects a <a href="/en-US/docs/JavaScript/Guide/Regular_Expressions">Regular Expression</a> as its value. A regular expression (regex) is a pattern that can be used to match character combinations in text strings, so they are ideal for form validation (as well as variety of other uses in JavaScript). Regexs are quite complex and we do not intend to teach you them exhaustively in this article.</p>
+
+<p>Below are some examples to give you a basic idea of how they work:</p>
+
+<ul>
+ <li><code>a</code> — matches one character that is a (not b, not aa, etc.)</li>
+ <li><code>abc</code> — matches <code>a</code>, followed by <code>b</code>, followed by <code>c</code>.</li>
+ <li><code>a*</code> — matches the character a, zero or more times (<code>+</code> matches a character one or more times).</li>
+ <li><code>[^a]</code> — matches one character that is <strong>not</strong> a.</li>
+ <li><code>a|b</code> — matches one character that is a or b.</li>
+ <li><code>[abc]</code> — matches one character that is a, b, or c.</li>
+ <li><code>[^abc]</code> — matches one character that is <strong>not</strong> a, b, or c.</li>
+ <li><code>[a-z]</code> — matches any character in the range a–z, lower case only (you can use <code>[A-Za-z]</code> for lower and upper case, and <code>[A-Z]</code> for upper case only).</li>
+ <li><code>a.c</code> — matches a, followed by any character, followed by c.</li>
+ <li><code>a{5}</code> — matches a, 5 times.</li>
+ <li><code>a{5,7}</code> — matches a, 5 to 7 times, but no less or more.</li>
+</ul>
+
+<p>You can use numbers and other characters in these expressions too, such as:</p>
+
+<ul>
+ <li><code>[ -]</code> — matches a space or a dash.</li>
+ <li><code>[0-9]</code> — matches any digit in the range 0 to 9.</li>
+</ul>
+
+<p>You can combine these in pretty much any way you want, specifying different parts one after the other:</p>
+
+<ul>
+ <li><code>[Ll].*k</code> — A single character that is an upper or lowercase L, followed by zero or more characters of any type, followed by a single lowercase k.</li>
+ <li><code>[A-Z][A-Za-z' -]+</code> — A single upper case character followed by one or more characters that are an upper or lower case letter, a dash, an apostrophe, or a space. This could be used to validate the city/town names of English-speaking countries, which need to start with a capital letter, but don't contain any other characters. Examples from the UK include Manchester, Ashton-under-lyne, and Bishop's Stortford.</li>
+ <li><code>[0-9]{3}[ -][0-9]{3}[ -][0-9]{4}</code> — A simple match for a US domestic phone number — three digits, followed by a space or a dash, followed by three digits, followed by a space or a dash, followed by four digits. You might have to make this more complex, as some people write their area code in parentheses, but it works for a simple demonstration.</li>
+</ul>
+
+<p>Anyway, let's implement an example — update your HTML to add a <code>pattern</code> attribute, like so:</p>
+
+<pre class="brush: html">&lt;form&gt;
+ &lt;label for="choose"&gt;Would you prefer a banana or a cherry?&lt;/label&gt;
+ &lt;input id="choose" name="i_like" required pattern="banana|cherry"&gt;
+ &lt;button&gt;Submit&lt;/button&gt;
+&lt;/form&gt;</pre>
+
+<div class="hidden">
+<pre class="brush: css">input:invalid {
+ border: 2px dashed red;
+}
+
+input:valid {
+ border: 2px solid black;
+}</pre>
+</div>
+
+<p>{{EmbedLiveSample("Validating_against_a_regular_expression", "100%", 50)}}</p>
+
+<p>In this example, the {{HTMLElement("input")}} element accepts one of two possible values: the string "banana" or the string "cherry".</p>
+
+<p>At this point, try changing the value inside the <code>pattern</code> attribute to equal some of the examples you saw earlier, and look at how that affects the values you can enter to make the input value valid. Try writing some of your own, and see how you get on! Try to make them fruit-related where possible, so your examples make sense!</p>
+
+<div class="note">
+<p><strong>Note:</strong> Some {{HTMLElement("input")}} element types do not need a {{htmlattrxref("pattern","input")}} attribute to be validated. Specifying the <code>email</code> type for example validates the inputted value against a regular expression matching a well-formed email address (or a comma-separated list of email addresses if it has the {{htmlattrxref("multiple","input")}} attribute). As a further example, fields with the <code>url</code> type automatically require a properly-formed URL.</p>
+</div>
+
+<div class="note">
+<p><strong>Note</strong>: The {{HTMLElement("textarea")}} element does not support the {{htmlattrxref("pattern","input")}} attribute.</p>
+</div>
+
+<h3 id="Constraining_the_length_of_your_entries">Constraining the length of your entries</h3>
+
+<p>All text fields created by ({{HTMLElement("input")}} or {{HTMLElement("textarea")}}) can be constrained in size using the {{htmlattrxref("minlength","input")}} and {{htmlattrxref("maxlength","input")}} attributes. A field is invalid if its value is shorter than the {{htmlattrxref("minlength","input")}} value or longer than the {{htmlattrxref("maxlength","input")}} value. Browsers often don't let the user type a longer value than expected into text fields anyway, but it is useful to have this fine-grained control available.</p>
+
+<p>For number fields (i.e. <code>&lt;input type="number"&gt;</code>), the {{htmlattrxref("min","input")}} and {{htmlattrxref("max","input")}} attributes also provide a validation constraint. If the field's value is lower than the {{htmlattrxref("min","input")}} attribute or higher than the {{htmlattrxref("max","input")}} attribute, the field will be invalid.</p>
+
+<p>Let's look at another example. Create a new copy of the <a href="https://github.com/mdn/learning-area/blob/master/html/forms/form-validation/fruit-start.html">fruit-start.html</a> file.</p>
+
+<p>Now delete the contents of the <code>&lt;body&gt;</code> element, and replace it with the following:</p>
+
+<pre class="brush: html">&lt;form&gt;
+ &lt;div&gt;
+ &lt;label for="choose"&gt;Would you prefer a banana or a cherry?&lt;/label&gt;
+ &lt;input id="choose" name="i_like" required minlength="6" maxlength="6"&gt;
+ &lt;/div&gt;
+ &lt;div&gt;
+ &lt;label for="number"&gt;How many would you like?&lt;/label&gt;
+ &lt;input type="number" id="number" name="amount" value="1" min="1" max="10"&gt;
+ &lt;/div&gt;
+ &lt;div&gt;
+ &lt;button&gt;Submit&lt;/button&gt;
+ &lt;/div&gt;
+&lt;/form&gt;</pre>
+
+<ul>
+ <li>Here you'll see that we've given the <code>text</code> field a <code>minlength</code> and <code>maxlength</code> of 6 — the same length as banana and cherry. Entering less characters will show as invalid, and entering more is not possible in most browsers.</li>
+ <li>We've also given the <code>number</code> field a <code>min</code> of 1 and a <code>max</code> of 10 — entered numbers outside this range will show as invalid, and you won't be able to use the increment/decrement arrows to move the value outside this range.</li>
+</ul>
+
+<div class="hidden">
+<pre>input:invalid {
+ border: 2px dashed red;
+}
+
+input:valid {
+ border: 2px solid black;
+}
+
+div {
+ margin-bottom: 10px;
+}</pre>
+</div>
+
+<p>Here is the example running live:</p>
+
+<p>{{EmbedLiveSample("Constraining_the_length_of_your_entries", "100%", 70)}}</p>
+
+<div class="note">
+<p><strong>Note</strong>: <code>&lt;input type="number"&gt;</code> (and other types, like <code>range</code>) can also take a {{htmlattrxref("step", "input")}} attribute, which specifies what increment the value will go up or down by when the input controls are used (like the up and down number buttons).</p>
+</div>
+
+<h3 id="Full_example">Full example</h3>
+
+<p>Here is a full example to show off usage of HTML's built-in validation features:</p>
+
+<pre class="brush: html">&lt;form&gt;
+ &lt;p&gt;
+ &lt;fieldset&gt;
+ &lt;legend&gt;Title&lt;abbr title="This field is mandatory"&gt;*&lt;/abbr&gt;&lt;/legend&gt;
+ &lt;input type="radio" required name="title" id="r1" value="Mr"&gt;&lt;label for="r1"&gt;Mr.&lt;/label&gt;
+ &lt;input type="radio" required name="title" id="r2" value="Ms"&gt;&lt;label for="r2"&gt;Ms.&lt;/label&gt;
+ &lt;/fieldset&gt;
+ &lt;/p&gt;
+ &lt;p&gt;
+ &lt;label for="n1"&gt;How old are you?&lt;/label&gt;
+ &lt;!-- The pattern attribute can act as a fallback for browsers which
+ don't implement the number input type but support the pattern attribute.
+ Please note that browsers that support the pattern attribute will make it
+ fail silently when used with a number field.
+ Its usage here acts only as a fallback --&gt;
+ &lt;input type="number" min="12" max="120" step="1" id="n1" name="age"
+ pattern="\d+"&gt;
+ &lt;/p&gt;
+ &lt;p&gt;
+ &lt;label for="t1"&gt;What's your favorite fruit?&lt;abbr title="This field is mandatory"&gt;*&lt;/abbr&gt;&lt;/label&gt;
+ &lt;input type="text" id="t1" name="fruit" list="l1" required
+ pattern="[Bb]anana|[Cc]herry|[Aa]pple|[Ss]trawberry|[Ll]emon|[Oo]range"&gt;
+ &lt;datalist id="l1"&gt;
+ &lt;option&gt;Banana&lt;/option&gt;
+ &lt;option&gt;Cherry&lt;/option&gt;
+ &lt;option&gt;Apple&lt;/option&gt;
+ &lt;option&gt;Strawberry&lt;/option&gt;
+ &lt;option&gt;Lemon&lt;/option&gt;
+ &lt;option&gt;Orange&lt;/option&gt;
+ &lt;/datalist&gt;
+ &lt;/p&gt;
+ &lt;p&gt;
+ &lt;label for="t2"&gt;What's your e-mail?&lt;/label&gt;
+ &lt;input type="email" id="t2" name="email"&gt;
+ &lt;/p&gt;
+ &lt;p&gt;
+ &lt;label for="t3"&gt;Leave a short message&lt;/label&gt;
+ &lt;textarea id="t3" name="msg" maxlength="140" rows="5"&gt;&lt;/textarea&gt;
+ &lt;/p&gt;
+ &lt;p&gt;
+ &lt;button&gt;Submit&lt;/button&gt;
+ &lt;/p&gt;
+&lt;/form&gt;</pre>
+
+<pre class="brush: css">body {
+ font: 1em sans-serif;
+ padding: 0;
+ margin : 0;
+}
+
+form {
+ max-width: 200px;
+ margin: 0;
+ padding: 0 5px;
+}
+
+p &gt; label {
+ display: block;
+}
+
+input[type=text],
+input[type=email],
+input[type=number],
+textarea,
+fieldset {
+/* required to properly style form
+ elements on WebKit based browsers */
+ -webkit-appearance: none;
+
+ width : 100%;
+ border: 1px solid #333;
+ margin: 0;
+
+ font-family: inherit;
+ font-size: 90%;
+
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+}
+
+input:invalid {
+ box-shadow: 0 0 5px 1px red;
+}
+
+input:focus:invalid {
+ outline: none;
+}</pre>
+
+<p>{{EmbedLiveSample("Full_example", "100%", 420)}}</p>
+
+<h3 id="Customized_error_messages">Customized error messages</h3>
+
+<p>As seen in the examples above, each time the user tries to submit an invalid form, the browser displays an error message. The way this message is displayed depends on the browser.</p>
+
+<p>These automated messages have two drawbacks:</p>
+
+<ul>
+ <li>There is no standard way to change their look and feel with CSS.</li>
+ <li>They depend on the browser locale, which means that you can have a page in one language but an error message displayed in another language.</li>
+</ul>
+
+<table>
+ <caption>French versions of feedback messages on an English page</caption>
+ <thead>
+ <tr>
+ <th scope="col">Browser</th>
+ <th scope="col">Rendering</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>Firefox 17 (Windows 7)</td>
+ <td><img alt="Example of an error message with Firefox in French on an English page" src="/files/4329/error-firefox-win7.png" style="height: 97px; width: 228px;"></td>
+ </tr>
+ <tr>
+ <td>Chrome 22 (Windows 7)</td>
+ <td><img alt="Example of an error message with Chrome in French on an English page" src="/files/4327/error-chrome-win7.png" style="height: 96px; width: 261px;"></td>
+ </tr>
+ <tr>
+ <td>Opera 12.10 (Mac OSX)</td>
+ <td><img alt="Example of an error message with Opera in French on an English page" src="/files/4331/error-opera-macos.png" style="height: 83px; width: 218px;"></td>
+ </tr>
+ </tbody>
+</table>
+
+<p>To customize the appearance and text of these messages, you must use JavaScript; there is no way to do it using just HTML and CSS.</p>
+
+<p>HTML5 provides the <a href="https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#the-constraint-validation-api" rel="external">constraint validation API</a> to check and customize the state of a form element. Among other things, it's possible to change the text of the error message. Let's see a quick example:</p>
+
+<pre class="brush: html">&lt;form&gt;
+ &lt;label for="mail"&gt;I would like you to provide me an e-mail&lt;/label&gt;
+ &lt;input type="email" id="mail" name="mail"&gt;
+ &lt;button&gt;Submit&lt;/button&gt;
+&lt;/form&gt;</pre>
+
+<p>In JavaScript, you call the <a href="/en-US/docs/HTML/HTML5/Constraint_validation#Constraint_API's_element.setCustomValidity()"><code>setCustomValidity()</code></a> method:</p>
+
+<pre class="brush: js">var email = document.getElementById("mail");
+
+email.addEventListener("input", function (event) {
+ if (email.validity.typeMismatch) {
+ email.setCustomValidity("I expect an e-mail, darling!");
+ } else {
+ email.setCustomValidity("");
+ }
+});</pre>
+
+<p>{{EmbedLiveSample("Customized_error_messages", "100%", 50)}}</p>
+
+<h2 id="Validating_forms_using_JavaScript">Validating forms using JavaScript</h2>
+
+<p>If you want to take control over the look and feel of native error messages, or if you want to deal with browsers that do not support HTML's built-in form validation, you must use JavaScript.</p>
+
+<h3 id="The_HTML5_constraint_validation_API">The HTML5 constraint validation API</h3>
+
+<p>More and more browsers now support the constraint validation API, and it's becoming reliable. This API consists of a set of methods and properties available on each form element.</p>
+
+<h4 id="Constraint_validation_API_properties">Constraint validation API properties</h4>
+
+<table>
+ <thead>
+ <tr>
+ <th scope="col">Property</th>
+ <th scope="col">Description</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><code>validationMessage</code></td>
+ <td>A localized message describing the validation constraints that the control does not satisfy (if any), or the empty string if the control is not a candidate for constraint validation (<code>willValidate</code> is <code>false</code>), or the element's value satisfies its constraints.</td>
+ </tr>
+ <tr>
+ <td><code>validity</code></td>
+ <td>A {{domxref("ValidityState")}} object describing the validity state of the element.</td>
+ </tr>
+ <tr>
+ <td><code>validity.customError</code></td>
+ <td>Returns <code>true</code> if the element has a custom error; <code>false</code> otherwise.</td>
+ </tr>
+ <tr>
+ <td><code>validity.patternMismatch</code></td>
+ <td>Returns <code>true</code> if the element's value doesn't match the provided pattern; <code>false</code> otherwise.<br>
+ <br>
+ If it returns <code>true</code>, the element will match the {{cssxref(":invalid")}} CSS pseudo-class.</td>
+ </tr>
+ <tr>
+ <td><code>validity.rangeOverflow</code></td>
+ <td>Returns <code>true</code> if the element's value is higher than the provided maximum; <code>false</code> otherwise.<br>
+ <br>
+ If it returns <code>true</code>, the element will match the {{cssxref(":invalid")}} and {{cssxref(":out-of-range")}} and CSS pseudo-class.</td>
+ </tr>
+ <tr>
+ <td><code>validity.rangeUnderflow</code></td>
+ <td>Returns <code>true</code> if the element's value is lower than the provided minimum; <code>false</code> otherwise.<br>
+ <br>
+ If it returns <code>true</code>, the element will match the {{cssxref(":invalid")}} and {{cssxref(":out-of-range")}} CSS pseudo-class.</td>
+ </tr>
+ <tr>
+ <td><code>validity.stepMismatch</code></td>
+ <td>Returns <code>true</code> if the element's value doesn't fit the rules provided by the step attribute; otherwise <code>false</code> .<br>
+ <br>
+ If it returns <code>true</code>, the element will match the {{cssxref(":invalid")}} and {{cssxref(":out-of-range")}} CSS pseudo-class.</td>
+ </tr>
+ <tr>
+ <td><code>validity.tooLong</code></td>
+ <td>Returns <code>true</code> if the element's value is longer than the provided maximum length; else it wil be false<br>
+ <br>
+ If it returns <code>true</code>, the element will match the {{cssxref(":invalid")}} and {{cssxref(":out-of-range")}} CSS pseudo-class.</td>
+ </tr>
+ <tr>
+ <td><code>validity.typeMismatch</code></td>
+ <td>Returns true if the element's value is not in the correct syntax; otherwise false.<br>
+ <br>
+ If it returns <code>true</code>, the element will match the {{cssxref(":invalid")}} CSS pseudo-class.</td>
+ </tr>
+ <tr>
+ <td><code>validity.valid</code></td>
+ <td>Returns true if the element's value has no validity problems; false otherwise.<br>
+ <br>
+ If it returns <code>true</code>, the element will match the {{cssxref(":valid")}} CSS pseudo-class; the {{cssxref(":invalid")}} CSS pseudo-class otherwise.</td>
+ </tr>
+ <tr>
+ <td><code>validity.valueMissing</code></td>
+ <td>Returns true if the element has no value but is a required field; false otherwise.<br>
+ <br>
+ If it returns <code>true</code>, the element will match the {{cssxref(":invalid")}} CSS pseudo-class.</td>
+ </tr>
+ <tr>
+ <td><code>willValidate</code></td>
+ <td>Returns <code>true</code> if the element will be validated when the form is submitted; <code>false</code> otherwise.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h4 id="Constraint_validation_API_methods">Constraint validation API methods</h4>
+
+<table>
+ <thead>
+ <tr>
+ <th scope="col">Method</th>
+ <th scope="col">Description</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><code>checkValidity()</code></td>
+ <td>Returns <code>true</code> if the element's value has no validity problems; <code>false</code> otherwise. If the element is invalid, this method also causes an {{event("invalid")}} event at the element.</td>
+ </tr>
+ <tr>
+ <td><code>setCustomValidity(<em>message</em>)</code></td>
+ <td>Adds a custom error message to the element; if you set a custom error message, the element is considered to be invalid, and the specified error is displayed. This lets you use JavaScript code to establish a validation failure other than those offered by the standard constraint validation API. The message is shown to the user when reporting the problem.<br>
+ <br>
+ If the argument is the empty string, the custom error is cleared.</td>
+ </tr>
+ </tbody>
+</table>
+
+<p>For legacy browsers, it's possible to use a <a href="https://hyperform.js.org/" rel="external">polyfill such as Hyperform </a> to compensate for the lack of support for the constraint validation API. Since you're already using JavaScript, using a polyfill isn't an added burden to your Web site or Web application's design or implementation.</p>
+
+<h4 id="Example_using_the_constraint_validation_API">Example using the constraint validation API</h4>
+
+<p>Let's see how to use this API to build custom error messages. First, the HTML:</p>
+
+<pre class="brush: html">&lt;form novalidate&gt;
+ &lt;p&gt;
+ &lt;label for="mail"&gt;
+ &lt;span&gt;Please enter an email address:&lt;/span&gt;
+ &lt;input type="email" id="mail" name="mail"&gt;
+ &lt;span class="error" aria-live="polite"&gt;&lt;/span&gt;
+ &lt;/label&gt;
+ &lt;/p&gt;
+ &lt;button&gt;Submit&lt;/button&gt;
+&lt;/form&gt;</pre>
+
+<p>This simple form uses the {{htmlattrxref("novalidate","form")}} attribute to turn off the browser's automatic validation; this lets our script take control over validation. However, this doesn't disable support for the constraint validation API nor the application of the CSS pseudo-class {{cssxref(":valid")}}, {{cssxref(":invalid")}}, {{cssxref(":in-range")}} and {{cssxref(":out-of-range")}} classes. That means that even though the browser doesn't automatically check the validity of the form before sending its data, you can still do it yourself and style the form accordingly.</p>
+
+<p>The <a href="/en-US/docs/Accessibility/ARIA/ARIA_Live_Regions"><code>aria-live</code></a> attribute makes sure that our custom error message will be presented to everyone, including those using assistive technologies such as screen readers.</p>
+
+<h5 id="CSS">CSS</h5>
+
+<p>This CSS styles our form and the error output to look more attractive.</p>
+
+<pre class="brush: css">/* This is just to make the example nicer */
+body {
+ font: 1em sans-serif;
+ padding: 0;
+ margin : 0;
+}
+
+form {
+ max-width: 200px;
+}
+
+p * {
+ display: block;
+}
+
+input[type=email]{
+ -webkit-appearance: none;
+
+ width: 100%;
+ border: 1px solid #333;
+ margin: 0;
+
+ font-family: inherit;
+ font-size: 90%;
+
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+}
+
+/* This is our style for the invalid fields */
+input:invalid{
+ border-color: #900;
+ background-color: #FDD;
+}
+
+input:focus:invalid {
+ outline: none;
+}
+
+/* This is the style of our error messages */
+.error {
+ width : 100%;
+ padding: 0;
+
+ font-size: 80%;
+ color: white;
+ background-color: #900;
+ border-radius: 0 0 5px 5px;
+
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+}
+
+.error.active {
+ padding: 0.3em;
+}</pre>
+
+<h5 id="JavaScript">JavaScript</h5>
+
+<p>The following JavaScript code handles the custom error validation.</p>
+
+<pre class="brush: js">// There are many ways to pick a DOM node; here we get the form itself and the email
+// input box, as well as the span element into which we will place the error message.
+
+var form = document.getElementsByTagName('form')[0];
+var email = document.getElementById('mail');
+var error = document.querySelector('.error');
+
+email.addEventListener("input", function (event) {
+ // Each time the user types something, we check if the
+ // email field is valid.
+ if (email.validity.valid) {
+ // In case there is an error message visible, if the field
+ // is valid, we remove the error message.
+ error.innerHTML = ""; // Reset the content of the message
+ error.className = "error"; // Reset the visual state of the message
+ }
+}, false);
+form.addEventListener("submit", function (event) {
+ // Each time the user tries to send the data, we check
+ // if the email field is valid.
+ if (!email.validity.valid) {
+
+ // If the field is not valid, we display a custom
+ // error message.
+ error.innerHTML = "I expect an e-mail, darling!";
+ error.className = "error active";
+ // And we prevent the form from being sent by canceling the event
+ event.preventDefault();
+ }
+}, false);</pre>
+
+<p>Here is the live result:</p>
+
+<p>{{EmbedLiveSample("Example_using_the_constraint_validation_API", "100%", 130)}}</p>
+
+<p>The constraint validation API gives you a powerful tool to handle form validation, letting you have enormous control over the user interface above and beyond what you can do just with HTML and CSS alone.</p>
+
+<h3 id="Validating_forms_without_a_built-in_API">Validating forms without a built-in API</h3>
+
+<p>Sometimes, such as with legacy browsers or <a href="/en-US/docs/HTML/Forms/How_to_build_custom_form_widgets">custom widgets</a>, you will not be able to (or will not want to) use the constraint validation API. In that case, you're still able to use JavaScript to validate your form. Validating a form is more a question of user interface than real data validation.</p>
+
+<p>To validate a form, you have to ask yourself a few questions:</p>
+
+<dl>
+ <dt>What kind of validation should I perform?</dt>
+ <dd>You need to determine how to validate your data: string operations, type conversion, regular expressions, etc. It's up to you. Just remember that form data is always text and is always provided to your script as strings.</dd>
+ <dt>What should I do if the form does not validate?</dt>
+ <dd>This is clearly a UI matter. You have to decide how the form will behave: Does the form send the data anyway? Should you highlight the fields which are in error? Should you display error messages?</dd>
+ <dt>How can I help the user to correct invalid data?</dt>
+ <dd>In order to reduce the user's frustration, it's very important to provide as much helpful information as possible in order to guide them in correcting their inputs. You should offer up-front suggestions so they know what's expected, as well as clear error messages. If you want to dig into form validation UI requirements, there are some useful articles you should read:
+ <ul>
+ <li>SmashingMagazine: <a href="http://uxdesign.smashingmagazine.com/2012/06/27/form-field-validation-errors-only-approach/" rel="external">Form-Field Validation: The Errors-Only Approach</a></li>
+ <li>SmashingMagazine: <a href="http://www.smashingmagazine.com/2009/07/07/web-form-validation-best-practices-and-tutorials/" rel="external">Web Form Validation: Best Practices and Tutorials</a></li>
+ <li>Six Revision: <a href="http://sixrevisions.com/user-interface/best-practices-for-hints-and-validation-in-web-forms/" rel="external">Best Practices for Hints and Validation in Web Forms</a></li>
+ <li>A List Apart: <a href="http://www.alistapart.com/articles/inline-validation-in-web-forms/" rel="external">Inline Validation in Web Forms</a></li>
+ </ul>
+ </dd>
+</dl>
+
+<h4 id="Example_that_doesn't_use_the_constraint_validation_API">Example that doesn't use the constraint validation API</h4>
+
+<p>In order to illustrate this, let's rebuild the previous example so that it works with legacy browsers:</p>
+
+<pre class="brush: html">&lt;form&gt;
+ &lt;p&gt;
+ &lt;label for="mail"&gt;
+ &lt;span&gt;Please enter an email address:&lt;/span&gt;
+ &lt;input type="text" class="mail" id="mail" name="mail"&gt;
+ &lt;span class="error" aria-live="polite"&gt;&lt;/span&gt;
+ &lt;/label&gt;
+ &lt;p&gt;
+ &lt;!-- Some legacy browsers need to have the `type` attribute
+ explicitly set to `submit` on the `button`element --&gt;
+ &lt;button type="submit"&gt;Submit&lt;/button&gt;
+&lt;/form&gt;</pre>
+
+<p>As you can see, the HTML is almost the same; we just removed the HTML validation features. Note that <a href="/en-US/docs/Accessibility/ARIA">ARIA</a> is an independent specification that's not specifically related to HTML5.</p>
+
+<h5 id="CSS_2">CSS</h5>
+
+<p>Similarly, the CSS doesn't need to change very much; we just turn the {{cssxref(":invalid")}} CSS pseudo-class into a real class and avoid using the attribute selector that does not work on Internet Explorer 6.</p>
+
+<pre class="brush: css">/* This is just to make the example nicer */
+body {
+ font: 1em sans-serif;
+ padding: 0;
+ margin : 0;
+}
+
+form {
+ max-width: 200px;
+}
+
+p * {
+ display: block;
+}
+
+input.mail {
+ -webkit-appearance: none;
+
+ width: 100%;
+ border: 1px solid #333;
+ margin: 0;
+
+ font-family: inherit;
+ font-size: 90%;
+
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+}
+
+/* This is our style for the invalid fields */
+input.invalid{
+ border-color: #900;
+ background-color: #FDD;
+}
+
+input:focus.invalid {
+ outline: none;
+}
+
+/* This is the style of our error messages */
+.error {
+ width : 100%;
+ padding: 0;
+
+ font-size: 80%;
+ color: white;
+ background-color: #900;
+ border-radius: 0 0 5px 5px;
+
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+}
+
+.error.active {
+ padding: 0.3em;
+}</pre>
+
+<h5 id="JavaScript_2">JavaScript</h5>
+
+<p>The big changes are in the JavaScript code, which needs to do much more of the heavy lifting.</p>
+
+<pre class="brush: js">// There are fewer ways to pick a DOM node with legacy browsers
+var form = document.getElementsByTagName('form')[0];
+var email = document.getElementById('mail');
+
+// The following is a trick to reach the next sibling Element node in the DOM
+// This is dangerous because you can easily build an infinite loop.
+// In modern browsers, you should prefer using element.nextElementSibling
+var error = email;
+while ((error = error.nextSibling).nodeType != 1);
+
+// As per the HTML5 Specification
+var emailRegExp = /^[a-zA-Z0-9.!#$%&amp;'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
+
+// Many legacy browsers do not support the addEventListener method.
+// Here is a simple way to handle this; it's far from the only one.
+function addEvent(element, event, callback) {
+ var previousEventCallBack = element["on"+event];
+ element["on"+event] = function (e) {
+ var output = callback(e);
+
+ // A callback that returns `false` stops the callback chain
+ // and interrupts the execution of the event callback.
+ if (output === false) return false;
+
+ if (typeof previousEventCallBack === 'function') {
+ output = previousEventCallBack(e);
+ if(output === false) return false;
+ }
+ }
+};
+
+// Now we can rebuild our validation constraint
+// Because we do not rely on CSS pseudo-class, we have to
+// explicitly set the valid/invalid class on our email field
+addEvent(window, "load", function () {
+ // Here, we test if the field is empty (remember, the field is not required)
+ // If it is not, we check if its content is a well-formed e-mail address.
+ var test = email.value.length === 0 || emailRegExp.test(email.value);
+
+ email.className = test ? "valid" : "invalid";
+});
+
+// This defines what happens when the user types in the field
+addEvent(email, "input", function () {
+ var test = email.value.length === 0 || emailRegExp.test(email.value);
+ if (test) {
+ email.className = "valid";
+ error.innerHTML = "";
+ error.className = "error";
+ } else {
+ email.className = "invalid";
+ }
+});
+
+// This defines what happens when the user tries to submit the data
+addEvent(form, "submit", function () {
+ var test = email.value.length === 0 || emailRegExp.test(email.value);
+
+ if (!test) {
+ email.className = "invalid";
+ error.innerHTML = "I expect an e-mail, darling!";
+ error.className = "error active";
+
+ // Some legacy browsers do not support the event.preventDefault() method
+ return false;
+ } else {
+ email.className = "valid";
+ error.innerHTML = "";
+ error.className = "error";
+ }
+});</pre>
+
+<p>The result looks like this:</p>
+
+<p>{{EmbedLiveSample("Example_that_doesn't_use_the_constraint_validation_API", "100%", 130)}}</p>
+
+<p>As you can see, it's not that hard to build a validation system on your own. The difficult part is to make it generic enough to use it both cross-platform and on any form you might create. There are many libraries available to perform form validation; you shouldn't hesitate to use them. Here are a few examples:</p>
+
+<ul>
+ <li>Standalone library
+ <ul>
+ <li><a href="http://rickharrison.github.com/validate.js/" rel="external">Validate.js</a></li>
+ </ul>
+ </li>
+ <li>jQuery plug-in:
+ <ul>
+ <li><a href="http://bassistance.de/jquery-plugins/jquery-plugin-validation/" rel="external">Validation</a></li>
+ </ul>
+ </li>
+</ul>
+
+<h4 id="Remote_validation">Remote validation</h4>
+
+<p>In some cases it can be useful to perform some remote validation. This kind of validation is necessary when the data entered by the user is tied to additional data stored on the server side of your application. One use case for this is registration forms, where you ask for a user name. To avoid duplication, it's smarter to perform an AJAX request to check the availability of the user name rather than asking the user to send the data, then send back the form with an error.</p>
+
+<p>Performing such a validation requires taking a few precautions:</p>
+
+<ul>
+ <li>It requires exposing an API and some data publicly; be sure it is not sensitive data.</li>
+ <li>Network lag requires performing asynchronous validation. This requires some UI work in order to be sure that the user will not be blocked if the validation is not performed properly.</li>
+</ul>
+
+<h2 id="Conclusion">Conclusion</h2>
+
+<p>Form validation does not require complex JavaScript, but it does require thinking carefully about the user. Always remember to help your user to correct the data they provide. To that end, be sure to:</p>
+
+<ul>
+ <li>Display explicit error messages.</li>
+ <li>Be permissive about the input format.</li>
+ <li>Point out exactly where the error occurs (especially on large forms).</li>
+</ul>
+
+<p>{{PreviousMenuNext("Learn/HTML/Forms/Sending_and_retrieving_form_data", "Learn/HTML/Forms/How_to_build_custom_form_widgets", "Learn/HTML/Forms")}}</p>
+
+<h2 id="In_this_module">In this module</h2>
+
+<ul>
+ <li><a href="/en-US/docs/Learn/HTML/Forms/Your_first_HTML_form">Your first HTML form</a></li>
+ <li><a href="/en-US/docs/Learn/HTML/Forms/How_to_structure_an_HTML_form">How to structure an HTML form</a></li>
+ <li><a href="/en-US/docs/Learn/HTML/Forms/The_native_form_widgets">The native form widgets</a></li>
+ <li><a href="/en-US/docs/Learn/HTML/Forms/Sending_and_retrieving_form_data">Sending form data</a></li>
+ <li><a href="/en-US/docs/Learn/HTML/Forms/Form_validation">Form data validation</a></li>
+ <li><a href="/en-US/docs/Learn/HTML/Forms/How_to_build_custom_form_widgets">How to build custom form widgets</a></li>
+ <li><a href="/en-US/docs/Learn/HTML/Forms/Sending_forms_through_JavaScript">Sending forms through JavaScript</a></li>
+ <li><a href="/en-US/docs/Learn/HTML/Forms/HTML_forms_in_legacy_browsers">HTML forms in legacy browsers</a></li>
+ <li><a href="/en-US/docs/Learn/HTML/Forms/Styling_HTML_forms">Styling HTML forms</a></li>
+ <li><a href="/en-US/docs/Learn/HTML/Forms/Advanced_styling_for_HTML_forms">Advanced styling for HTML forms</a></li>
+ <li><a href="/en-US/docs/Learn/HTML/Forms/Property_compatibility_table_for_form_widgets">Property compatibility table for form widgets</a></li>
+</ul>
diff --git a/files/el/learn/html/index.html b/files/el/learn/html/index.html
new file mode 100644
index 0000000000..e2fcdc4043
--- /dev/null
+++ b/files/el/learn/html/index.html
@@ -0,0 +1,58 @@
+---
+title: 'Learning HTML: Guides and tutorials'
+slug: Learn/HTML
+tags:
+ - Beginner
+ - Guide
+ - HTML
+ - Intro
+ - Learn
+ - NeedsTranslation
+ - Topic
+ - TopicStub
+translation_of: Learn/HTML
+---
+<div>{{LearnSidebar}}</div>
+
+<p class="summary">To build websites, you should know about {{Glossary('HTML')}} — the fundamental technology used to define the structure of a webpage. HTML is used to specify whether your web content should be recognized as a paragraph, list, heading, link, image, multimedia player, form, or one of many other available elements or even a new element that you define.</p>
+
+<h2 id="Learning_pathway">Learning pathway</h2>
+
+<p>Ideally you should start your learning journey by learning HTML. Start by reading <a href="/en-US/docs/Web/Guide/HTML/Introduction">Introduction to HTML</a>. You may then move on to learning about more advanced topics such as:</p>
+
+<ul>
+ <li><a href="/en-US/docs/Learn/CSS">CSS</a>, and how to use it to style HTML (for example alter your text size and fonts used, add borders and drop shadows, layout your page with multiple columns, add animations and other visual effects.)</li>
+ <li><a href="/en-US/docs/Learn/JavaScript">JavaScript</a>, and how to use it to add dynamic functionality to web pages (for example find your location and plot it on a map, make UI elements appear/disappear when you toggle a button, save users' data locally on their computers, and much much more.)</li>
+</ul>
+
+<p>Before starting this topic, you should have at least basic familiarity with using computers, and using the web passively (i.e. just looking at it, consuming the content). You should have a basic work environment set up as detailed in <a href="/en-US/docs/Learn/Getting_started_with_the_web/Installing_basic_software">Installing basic software</a>, and understand how to create and manage files, as detailed in <a href="/en-US/docs/Learn/Getting_started_with_the_web/Dealing_with_files">Dealing with files</a> — both are parts of our <a href="/en-US/docs/Learn/Getting_started_with_the_web">Getting started with the web</a> complete beginner's module.</p>
+
+<p>It is recommended that you work through <a href="/en-US/docs/Learn/Getting_started_with_the_web">Getting started with the web </a>before attempting this topic, however it isn't absolutely necessary; much of what is covered in the <a href="/en-US/docs/Learn/Getting_started_with_the_web/HTML_basics">HTML basics</a> article is also covered in our <a href="/en-US/docs/Learn/HTML/Introduction_to_HTML">Introduction to HTML</a> module, albeit in a lot more detail.</p>
+
+<h2 id="Modules">Modules</h2>
+
+<p>This topic contains the following modules, in a suggested order for working through them. You should definitely start with the first one.</p>
+
+<dl>
+ <dt><a href="/en-US/docs/Learn/HTML/Introduction_to_HTML">Introduction to HTML</a></dt>
+ <dd>This module sets the stage, getting you used to important concepts and syntax, looking at applying HTML to text, how to create hyperlinks, and how to use HTML to structure a webpage.</dd>
+ <dt><a href="/en-US/docs/Learn/HTML/Multimedia_and_embedding">Multimedia and embedding</a></dt>
+ <dd>This module explores how to use HTML to include multimedia in your web pages, including the different ways that images can be included, and how to embed video, audio, and even entire other webpages.</dd>
+ <dt><a href="/en-US/docs/Learn/HTML/Tables">HTML Tables</a></dt>
+ <dd>Representing tabular data on a webpage in an understandable, {{glossary("Accessibility", "accessible")}} way can be a challenge. This module covers basic table markup, along with more complex features such as implementing captions and summaries.</dd>
+ <dt><a href="/en-US/docs/Learn/HTML/Forms">HTML Forms</a></dt>
+ <dd>Forms are a very important part of the Web — these provide much of the functionality you need for interacting with web sites, e.g. registering and logging in, sending feedback, buying products, and more. This module gets you started with creating the client-side parts of forms.</dd>
+</dl>
+
+<h2 id="Solving_common_HTML_problems">Solving common HTML problems</h2>
+
+<p><a href="/en-US/docs/Learn/HTML/Howto">Use HTML to solve common problems</a> provides links to sections of content explaining how to use HTML to solve very common problems when creating a webpage: dealing with titles, adding images or videos, emphasizing content, creating a basic form, etc.</p>
+
+<h2 id="See_also">See also</h2>
+
+<div class="document-head" id="wiki-document-head">
+<dl>
+ <dt><a href="/en-US/docs/Web/HTML">HTML (HyperText Markup Language)</a> on MDN</dt>
+ <dd>The main entry point for HTML documentation on MDN, including detailed element and attribute references — if you want to know what attributes an element has or what values an attribute has, for example, this is a great place to start.</dd>
+</dl>
+</div>