简体   繁体   English

预输出表格不可提交表格价值 - HTML

[英]Preinput Form Non Submitable Form Value- HTML

<input name="price" id="asdprice" value="" type="text">

I do not wish to use any JS if possible 如果可能的话,我不想使用任何JS

As you can see the value field is empty, and I do not want to prefill it as it will be submitable. 正如您所看到的,value字段为空,我不想预先填充它,因为它可以被提交。

What I want is a prefilled text area, with lets say 我想要的是一个预填充的文本区域,让我们说

http://www.  

as i would like that to be a valid format for that field, normally such filled input will be less opaque. 因为我希望它是该字段的有效格式,通常这样的填充输入将不那么不透明。

You can display a hint for the user to enter a valid URI using an input placeholder attribute: 您可以使用输入占位符属性显示用户输入有效URI的提示:

<input name="price" id="adsprice" type="text" placeholder="http://">

However the placeholder text will disappear once the field comes into focus. 但是,一旦字段成为焦点,占位符文本将消失。 You should be aware that users will enter all kinds of rubbish into form fields, so always validate the input on the server-side and prepend the http:// if it's missing. 您应该知道用户会在表单字段中输入所有类型的垃圾,因此请始终在服务器端验证输入并在http://前面添加它,如果它丢失了。

BTW, there are valid URIs that do not begin with http://www. 顺便说一句,有些有效的URI不是以http://www.开头的http://www. and not all sites redirect the www. 并非所有网站都重定向www。 subdomain as you would expect. 如你所料的子域名。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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