Html form action none

Содержание
  1. : The Form element
  2. Try it
  3. Attributes
  4. Attributes for form submission
  5. Examples
  6. Result
  7. Technical summary
  8. Specifications
  9. Browser compatibility
  10. See also
  11. Found a content problem with this page?
  12. MDN
  13. Support
  14. Our communities
  15. Developers
  16. CSP: form-action
  17. Syntax
  18. Sources
  19. Examples
  20. Meta tag configuration
  21. Apache configuration
  22. Nginx configuration
  23. Violation case
  24. Specifications
  25. Browser compatibility
  26. See also
  27. Found a content problem with this page?
  28. Html form action none
  29. Если атрибут action отсутствует или пустой
  30. Синтаксис атрибута action.
  31. Значения атрибута action.
  32. Что надо писать в атрибуте action в теге form
  33. Что ставить в action form?
  34. Обязательный атрибут атрибута action.
  35. Значение по умолчанию атрибута action.
  36. Пример использования атрибута action с якорем.
  37. Соберем код использования атрибута action.
  38. Выполнение атрибута action на другой странице
  39. Испытать пример работы атрибута action на другой странице
  40. Скачать пример использования атрибута action на другой странице
  41. Выполнение атрибута action в новом окне
  42. HTML Form Attributes
  43. The Action Attribute
  44. Example
  45. The Target Attribute
  46. Example
  47. The Method Attribute
  48. Example
  49. Example
  50. The Autocomplete Attribute
  51. Example
  52. The Novalidate Attribute
  53. Example
  54. HTML Exercises
  55. List of All Attributes

: The Form element

The HTML element represents a document section containing interactive controls for submitting information.

Try it

It is possible to use the :valid and :invalid CSS pseudo-classes to style a element based on whether the elements inside the form are valid.

Attributes

This element includes the global attributes.

Comma-separated content types the server accepts.

Note: This attribute has been deprecated and should not be used. Instead, use the accept attribute on elements.

Space-separated character encodings the server accepts. The browser uses them in the order in which they are listed. The default value means the same encoding as the page. (In previous versions of HTML, character encodings could also be delimited by commas.)

Читайте также:  Как открыть черепашку в питоне

A nonstandard attribute used by iOS Safari that controls how textual form elements should be automatically capitalized. autocapitalize attributes on a form elements override it on . Possible values:

  • none : No automatic capitalization.
  • sentences (default): Capitalize the first letter of each sentence.
  • words : Capitalize the first letter of each word.
  • characters : Capitalize all characters — that is, uppercase.

Indicates whether input elements can by default have their values automatically completed by the browser. autocomplete attributes on form elements override it on . Possible values:

  • off : The browser may not automatically complete entries. (Browsers tend to ignore this for suspected login forms; see The autocomplete attribute and login fields.)
  • on : The browser may automatically complete entries.

The name of the form. The value must not be the empty string, and must be unique among the form elements in the forms collection that it is in, if any.

Controls the annotations and what kinds of links the form creates. Annotations include external , nofollow , opener , noopener , and noreferrer . Link types include help , prev , next , search , and license . The rel value is a space-separated list of these enumerated values.

Attributes for form submission

The following attributes control behavior during form submission.

The URL that processes the form submission. This value can be overridden by a formaction attribute on a , , or element. This attribute is ignored when method=»dialog» is set.

If the value of the method attribute is post , enctype is the MIME type of the form submission. Possible values:

  • application/x-www-form-urlencoded : The default value.
  • multipart/form-data : Use this if the form contains elements with type=file .
  • text/plain : Useful for debugging purposes.

This value can be overridden by formenctype attributes on , , or elements.

The HTTP method to submit the form with. The only allowed methods/values are (case insensitive):

  • post : The POST method; form data sent as the request body.
  • get (default): The GET ; form data appended to the action URL with a ? separator. Use this method when the form has no side effects.
  • dialog : When the form is inside a , closes the dialog and causes a submit event to be fired on submission, without submitting data or clearing the form.

This value is overridden by formmethod attributes on , , or elements.

This Boolean attribute indicates that the form shouldn’t be validated when submitted. If this attribute is not set (and therefore the form is validated), it can be overridden by a formnovalidate attribute on a , , or element belonging to the form.

Indicates where to display the response after submitting the form. It is a name/keyword for a browsing context (for example, tab, window, or iframe). The following keywords have special meanings:

  • _self (default): Load into the same browsing context as the current one.
  • _blank : Load into a new unnamed browsing context. This provides the same behavior as setting rel=»noopener» which does not set window.opener .
  • _parent : Load into the parent browsing context of the current one. If no parent, behaves the same as _self .
  • _top : Load into the top-level browsing context (i.e., the browsing context that is an ancestor of the current one and has no parent). If no parent, behaves the same as _self .

This value can be overridden by a formtarget attribute on a , , or element.

Examples

form method="get"> label> Name: input name="submitted-name" autocomplete="name" /> label> button>Savebutton> form> form method="post"> label> Name: input name="submitted-name" autocomplete="name" /> label> button>Savebutton> form> form method="post"> fieldset> legend>Do you agree to the terms?legend> label>input type="radio" name="radio" value="yes" /> Yeslabel> label>input type="radio" name="radio" value="no" /> Nolabel> fieldset> form> 

Result

Technical summary

Content categories Flow content, palpable content
Permitted content Flow content, but not containing elements
Tag omission None, both the starting and ending tag are mandatory.
Permitted parents Any element that accepts flow content
Implicit ARIA role form if the form has an accessible name, otherwise no corresponding role
Permitted ARIA roles search , none or presentation
DOM interface HTMLFormElement

Specifications

Browser compatibility

BCD tables only load in the browser

See also

Found a content problem with this page?

This page was last modified on Jun 13, 2023 by MDN contributors.

Your blueprint for a better internet.

MDN

Support

Our communities

Developers

Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998– 2023 by individual mozilla.org contributors. Content available under a Creative Commons license.

Источник

CSP: form-action

The HTTP Content-Security-Policy (CSP) form-action directive restricts the URLs which can be used as the target of form submissions from a given context.

Warning: Whether form-action should block redirects after a form submission is debated and browser implementations of this aspect are inconsistent (e.g. Firefox 57 doesn’t block the redirects whereas Chrome 63 does).

Syntax

One or more sources can be set for the form-action policy:

Content-Security-Policy: form-action ; Content-Security-Policy: form-action ; 

Sources

can be any one of the values listed in CSP Source Values.

Note that this same set of values can be used in all fetch directives (and a number of other directives).

Examples

Meta tag configuration

meta http-equiv="Content-Security-Policy" content="form-action 'none'" /> 

Apache configuration

IfModule mod_headers.c> Header set Content-Security-Policy "form-action 'none';" IfModule> 

Nginx configuration

add_header Content-Security-Policy "form-action 'none';"

Violation case

meta http-equiv="Content-Security-Policy" content="form-action 'none'" /> form action="javascript:alert('Foo')" id="form1" method="post"> input type="text" name="fieldName" value="fieldValue" /> input type="submit" id="submit" value="submit" /> form>  

Specifications

Browser compatibility

BCD tables only load in the browser

See also

Found a content problem with this page?

This page was last modified on Apr 10, 2023 by MDN contributors.

Your blueprint for a better internet.

Источник

Html form action none

Начнем с определения — «что такое атрибут action«:

Ссылка может быть пустой, тогда страница просто перезагрузится.

Если ссылка ведет на другую страницу, то браузер откроет другую страницу для выполнения кода!

Если атрибут action отсутствует или пустой

Страница будет перезагружена и если на этой странице есть скрипт, который привязан к этой форме он выполнится.

Синтаксис атрибута action.

Значения атрибута action.

Что надо писать в атрибуте action в теге form

Интересный поисковый запрос : «что надо писать в атрибуте action в теге form«? Или ещё : «для чего нужен action html»

Что ставить в action form?

Если php обработчик находится на другой странице — пишем адрес вашего «php файла»(подробнее).

Если требуется перейти по какому-то якорю на данной же странице(подробнее) :

Обязательный атрибут атрибута action.

В HTML4 и XHTML обязателен, в HTML5 не обязателен.

Значение по умолчанию атрибута action.

Пример использования атрибута action с якорем.

Также нам потребуется кнопка(можно input) с типом submit, по которой будем отправлять атрибут action

В action помещаем якорь, чтобы переместиться в заданную точку, после выполнения скрипта.

Перед формой ставим сам якорь:

Далее нам нужно обработать отправленный POST — у нас это php.

Если кнопка отправить будет нажата, то присваиваем значение переменной

Где нам требуется выводим результат, естественно ниже выше приведенного условия!

Соберем код использования атрибута action.

Теперь возьмем данный код с атрибутом action и разместим прямо здесь:
Результат использования type=»submit» в кнопке

Нажмите кнопку » Отправить »

Выполнение атрибута action на другой странице

Следующим — разберем использование атрибута action для выполнения скрипта на другой тсранице!

Для этого нам потребуется:

Сделаем отдельную страницу :

Если вы собираетесь использовать php в html? то вам понадобится — как включить php в html.

Далее все те пункты, которые мы рассматривали выше относительно формы(не будем повторять — выведем сразу код нашей формы!). В атрибут action помещаем ссылку, на страницу, что была приведена выше.

Испытать пример работы атрибута action на другой странице

Нажмите кнопку отправить, чтобы получить результат!

Скачать пример использования атрибута action на другой странице

Выполнение атрибута action в новом окне

Берем выше приведенный код и вставляем в тег «form»

Источник

HTML Form Attributes

This chapter describes the different attributes for the HTML element.

The Action Attribute

The action attribute defines the action to be performed when the form is submitted.

Usually, the form data is sent to a file on the server when the user clicks on the submit button.

In the example below, the form data is sent to a file called «action_page.php». This file contains a server-side script that handles the form data:

Example

On submit, send form data to «action_page.php»:

Tip: If the action attribute is omitted, the action is set to the current page.

The Target Attribute

The target attribute specifies where to display the response that is received after submitting the form.

The target attribute can have one of the following values:

Value Description
_blank The response is displayed in a new window or tab
_self The response is displayed in the current window
_parent The response is displayed in the parent frame
_top The response is displayed in the full body of the window
framename The response is displayed in a named iframe

The default value is _self which means that the response will open in the current window.

Example

Here, the submitted result will open in a new browser tab:

The Method Attribute

The method attribute specifies the HTTP method to be used when submitting the form data.

The form-data can be sent as URL variables (with method=»get» ) or as HTTP post transaction (with method=»post» ).

The default HTTP method when submitting form data is GET.

Example

This example uses the GET method when submitting the form data:

Example

This example uses the POST method when submitting the form data:

  • Appends the form data to the URL, in name/value pairs
  • NEVER use GET to send sensitive data! (the submitted form data is visible in the URL!)
  • The length of a URL is limited (2048 characters)
  • Useful for form submissions where a user wants to bookmark the result
  • GET is good for non-secure data, like query strings in Google
  • Appends the form data inside the body of the HTTP request (the submitted form data is not shown in the URL)
  • POST has no size limitations, and can be used to send large amounts of data.
  • Form submissions with POST cannot be bookmarked

Tip: Always use POST if the form data contains sensitive or personal information!

The Autocomplete Attribute

The autocomplete attribute specifies whether a form should have autocomplete on or off.

When autocomplete is on, the browser automatically complete values based on values that the user has entered before.

Example

A form with autocomplete on:

The Novalidate Attribute

The novalidate attribute is a boolean attribute.

When present, it specifies that the form-data (input) should not be validated when submitted.

Example

A form with a novalidate attribute:

HTML Exercises

List of All Attributes

Attribute Description
accept-charset Specifies the character encodings used for form submission
action Specifies where to send the form-data when a form is submitted
autocomplete Specifies whether a form should have autocomplete on or off
enctype Specifies how the form-data should be encoded when submitting it to the server (only for method=»post»)
method Specifies the HTTP method to use when sending form-data
name Specifies the name of the form
novalidate Specifies that the form should not be validated when submitted
rel Specifies the relationship between a linked resource and the current document
target Specifies where to display the response that is received after submitting the form

Источник

Оцените статью