From 980fe00a74a9ad013b945755415ace2e5429c3c2 Mon Sep 17 00:00:00 2001 From: Alexey Pyltsyn Date: Wed, 27 Oct 2021 02:31:24 +0300 Subject: [RU] Remove notranslate (#2874) --- files/ru/web/html/element/input/date/index.html | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'files/ru/web/html/element/input/date') diff --git a/files/ru/web/html/element/input/date/index.html b/files/ru/web/html/element/input/date/index.html index 23d6d631cc..d6f809030c 100644 --- a/files/ru/web/html/element/input/date/index.html +++ b/files/ru/web/html/element/input/date/index.html @@ -54,7 +54,7 @@ translation_of: Web/HTML/Element/input/date

Возвращает {{domxref("DOMString")}}, представляющий значение даты введённой в input. Вы можете установить значение по умолчанию для элемента с помощью добавления атрибута в {{htmlattrxref("value", "input")}}, например:

-
<input id="date" type="date" value="2017-06-01">
+
<input id="date" type="date" value="2017-06-01">

{{EmbedLiveSample('Значение', 600, 40)}}

@@ -64,7 +64,7 @@ translation_of: Web/HTML/Element/input/date

Вы также можете получить или установить значение даты в JavaScript с помощью свойств {{domxref("HTMLInputElement.value", "value")}} и {{domxref("HTMLInputElement.valueAsNumber", "valueAsNumber")}} элемента input. Например:

-
var dateControl = document.querySelector('input[type="date"]');
+
var dateControl = document.querySelector('input[type="date"]');
 dateControl.value = '2017-06-01';
 console.log(dateControl.value); // prints "2017-06-01"
 console.log(dateControl.valueAsNumber); // prints 1496275200000, a JavaScript timestamp (ms)
@@ -135,7 +135,7 @@ console.log(dateControl.valueAsNumber); // prints 1496275200000, a JavaScript ti
 
 

Самый простой способ использовать <input type="date"> - это использовать его с элементами <input> и label, как показано ниже:

-
<form>
+
<form>
   <div>
     <label for="bday">Введите дату вашего рождения:</label>
     <input type="date" id="bday" name="bday">
@@ -148,7 +148,7 @@ console.log(dateControl.valueAsNumber); // prints 1496275200000, a JavaScript ti
 
 

Вы можете использовать атрибуты {{htmlattrxref("min", "input")}} и {{htmlattrxref("max", "input")}}, чтобы ограничить дату, которую может выбрать пользователь. В следующем примере мы устанавливаем минимальную дату 2017-04-01 и максимальную дату 2017-04-30. Пользователь сможет выбрать дату только из этого диапазона:

-
<form>
+
<form>
   <div>
     <label for="party">Укажите предпочтительную дату события:</label>
     <input type="date" id="party" name="party" min="2017-04-01" max="2017-04-30">
@@ -177,7 +177,7 @@ console.log(dateControl.valueAsNumber); // prints 1496275200000, a JavaScript ti
 
 

Let's look at an example — here we've set minimum and maximum dates, and also made the field required:

-
<form>
+
<form>
   <div>
     <label for="party">Choose your preferred party date (required, April 1st to 20th):</label>
     <input type="date" id="party" name="party" min="2017-04-01" max="2017-04-20" required>
@@ -198,7 +198,7 @@ console.log(dateControl.valueAsNumber); // prints 1496275200000, a JavaScript ti
 
 

Here's the CSS used in the above example. Here we make use of the {{cssxref(":valid")}} and {{cssxref(":invalid")}} CSS properties to style the input based on whether or not the current value is valid. We had to put the icons on a {{htmlelement("span")}} next to the input, not on the input itself, because in Chrome the generated content is placed inside the form control, and can't be styled or shown effectively.

-
div {
+
div {
     margin-bottom: 10px;
     display: flex;
     align-items: center;
@@ -244,7 +244,7 @@ input:valid+span:after {
 
 

One way around this is to put a {{htmlattrxref("pattern", "input")}} attribute on your date input. Even though the date input doesn't use it, the text input fallback will. For example, try viewing the following example in a non-supporting browser:

-
<form>
+
<form>
   <div>
     <label for="bday">Enter your birthday:</label>
     <input type="date" id="bday" name="bday" required pattern="[0-9]{4}-[0-9]{2}-[0-9]{2}">
@@ -260,7 +260,7 @@ input:valid+span:after {
 

If you try submitting it, you'll see that the browser now displays an error message (and highlights the input as invalid) if your entry doesn't match the pattern nnnn-nn-nn, where n is a number from 0 to 9. Of course, this doesn't stop people from entering invalid dates, or incorrectly formatted dates, such as yyyy-dd-mm (whereas we want yyyy-mm-dd). So we still have a problem.