PHP联系表单覆盖字段问题重复值
我正在使用 http://phpfmg.sourceforge.net/home.php。我想我应该添加一个焦点效果,这样当我单击字段时,值会自动消失。
但是当我提交时,如果没有填写我的必填字段,我会得到这个值再次出现,就像 http://s647.photobucket.com/ albums/uu199/judibluebottles/YETI%20images/?action=view¤t=form_issue.jpg http://i647.photobucket.com/albums/uu199/judibluebottles/YETI%20images/form_issue.jpg?t=1268387405
<input type="text" class="text_box" onfocus="if(this.value=='Telephone')this.value='';" value="TelephoneTelephone" id="field_5" name="field_5">
H I'm using php contact form from http://phpfmg.sourceforge.net/home.php. I thought I'd add an onfocus effect so when i click in the fields the value dissappears automatically.
But when I submit say if haven't filled in my requried fields I get this the values appearing again like
http://s647.photobucket.com/albums/uu199/judibluebottles/YETI%20images/?action=view¤t=form_issue.jpg http://i647.photobucket.com/albums/uu199/judibluebottles/YETI%20images/form_issue.jpg?t=1268387405
<input type="text" class="text_box" onfocus="if(this.value=='Telephone')this.value='';" value="TelephoneTelephone" id="field_5" name="field_5">
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要在表单上使用
onsubmit
处理程序,该处理程序执行与onfocus
相同的操作:如果文本是默认文本,则将文本从框中清除。这样,提交时这些字段将为空。为此,我会放置一些结构以避免重复代码。 完全即兴:
字段的
onfocus
:表单的
onsubmit
:You'll want to use an
onsubmit
handler on the form that does the same thing theonfocus
does: Clears the text out of the box if it's the default text. That way, the fields will be blank when they're submitted.To do that, I'd put some structure in place to avoid duplicating code. Completely off the cuff:
onfocus
for fields:onsubmit
for form:我已经放弃了复杂的 php 联系表单,除非有人有一个几乎可以做任何事情的奇迹?对于 WordPress,contactform 7 是我遇到过的最简单的。
如果有人为 pixie cms 制作一个高级插件那就太好了:)
I've given up doing complicated php contact forms unless someone has a miracle one that can do almost anything? For Wordpress contactform 7 is the easiest i've come across.
Would be great is someone makes an advanced plugin for pixie cms :)