sandbox
sandbox

Reputation: 2679

HTML Email Form Error

In the following HTML form I am unable to derive the username. Is it because of using "ID" instead of "NAME"? Do suggest an alternative to overcome this problem.

   <form action="mailto:demo@demo" method="post" enctype="text/pain">
   Username:<input type="text" id="usr"/>
   Password:<input type="password" name="pwd"/>
   <input type="submit"/>
   </form>

Upvotes: 0

Views: 95

Answers (2)

talha2k
talha2k

Reputation: 1

To access values you should use names, modify your code like this:

<form action="mailto:demo@demo" method="post" enctype="text/pain">
   Username:<input type="text" name="usr"/>
   Password:<input type="password" name="pwd"/>
   <input type="submit"/>
</form>

and then you can access those values by usr and pwd variables.

Hope this helps.

Upvotes: 0

Pekka
Pekka

Reputation: 449425

Is it because of using "ID" instead of "NAME"?

Yup. From the manual:

A control's "control name" is given by its name attribute. The scope of the name attribute for a control within a FORM element is the FORM element.

Use the name property instead.

Upvotes: 4

Related Questions