简体   繁体   中英

Can the name attribute of the input of the HTML form not have the same value as the type attribute?

Can the name attribute of the input of the HTML form not have the same value as the type attribute?

I found when I'm using the input's name and input's type as the same attribute, some function will no word.

The type attribute needs to be one of the valid available values, such as text or password.

The name attribute is something you define.

Possible reason why sometimes things don't work for you when they're the same value is that maybe you've given type attribute a value that's not valid for it.

For example:

<input type="coupon" name="coupon">    <!-- This won't work, type "coupon" doesn't exist -->
<input type="password" name="password"> <!-- This will work -->
<input type="text" name="coupon"> <!-- This will work -->

The second one will work, because password is a valid value for the type attribute. The first one won't work, because there's no such input type as "coupon". So that type needs to be changed to "text".

It's an easy mistake to make, so I suggest check that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM