What html5 form attribute should be used for a zipcode?

前端 未结 8 2037
我寻月下人不归
我寻月下人不归 2021-02-01 02:51

Is it best to use a \'text\' attribute with a limit on the number of characters, or can I use a number attribute in an input for a zipcode.

Just trying to get my head ar

8条回答
  •  暖寄归人
    2021-02-01 03:29

    You can use either and the form will work. However, it might be a better idea to use number because, for example, mobile devices would invoke a different keyboard layout - with numbers and helper characters instead of the full alphanum keyboard.

    But, if you think setting one type as opposed to another will offer a higher level of security, you're wrong. No matter which type you put, it will offer you no security. Every form input needs to be checked on the server as well - that's where the real security check happens. The check that you do in browser, is more of a UI/UX thing.

    Here is a nice article about different input types: http://html5doctor.com/html5-forms-input-types/

提交回复
热议问题