1

如果有人将其留空,我想让我的网络提交不向我发送字段中的默认 txt。我不是一个超级程序员,我花了好几个小时试图让它今天工作,并且需要处理其他代码部分。

<form action="{SUBMIT_FORM}" method="post">

<input type="text" class="input-field"  onblur="if (this.value == '') {this.value = '*First Name : (Required Field)';}" onfocus="if (this.value == '*First Name : (Required Field)') {this.value = '';}" name="{lead_first_name}" id="{lead_first_name}" value="*First Name : (Required Field)"/>

<input type="text" class="input-field"  onblur="if (this.value == '') {this.value = 'Last Name :';}" onfocus="if (this.value == 'Last Name :') {this.value = '';}" name="{lead_last_name}" id="{lead_last_name}" value="Last Name :"/>

<input type="text" class="input-field"  onblur="if (this.value == '') {this.value = '*Email : (Required Field)';}" onfocus="if (this.value == '*Email : (Required Field)') {this.value = '';}" name="{lead_email}" id="{lead_email}" value="*Email : (Required Field)"/>

<input type="text" class="input-field" onblur="if (this.value == '') {this.value = 'Phone :';}" onfocus="if (this.value == 'Phone :') {this.value = '';}" name="{lead_home_phone}" id="{lead_home_phone}" value="Phone :"/>

<input type="submit" class="sbt-btn" value="Submit"  onclick="{SUBMIT_SCRIPT}" />


{VALIDATE_SCRIPT}
 </form>
<small>*We promise to never share, rent or sale your personal information.</small>
4

2 回答 2

3

尝试将默认值放在“占位符”属性而不是“值”中。

于 2012-10-29T21:03:32.397 回答
1

首先,尽可能避免使用内联 HTML 事件处理程序。

其次,您可能希望使用输入占位符 (HTML5) 而不是设置值:

<input type="text" name="{lead_first_name}" placeholder="First name" />

对于那些不支持的浏览器如 IE(9 及更早版本)placeholder,你可以这样

于 2012-10-29T21:07:17.727 回答