使用HTML5输入类型和jQuery [英] Using HTML5 input types and jQuery

查看:106
本文介绍了使用HTML5输入类型和jQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含以下字段的表单(此字段只是4中的一个)

I have a form with the following field(this field is just one of 4)

<input type="email" name="email" id="email" size="30" class="text-input" />

如果我在jquery中使用它,表单按预期工作:

If I use this in jquery the form works as expected:

var dataString = 'name='+ name + '&email=' + email + '&message=' + message + '&ip=' + ip + '&date=' + date;

但是,如果我使用它来缩短代码,则在提交时完全忽略电子邮件输入。

However if I use this to shorten the code, the email input is totally ignored on submit.

var dataString = $('#contact').serialize();

这是一个错误还是我看不到的东西。两者有什么区别?如果我将电子邮件输入更改为text,则表单将使用serialize

Is this a bug or is there something Im not seeing. What is the difference between the two? If I change the email input to "text" then the form works with serialize

使用jquery 1.6.0

Using jquery 1.6.0

推荐答案

我最近遇到了同样的问题,结果发现我使用的是jQuery 1.3.2!

I had the same issue recently, and it turned out I was using jQuery 1.3.2!

升级到1.6.2 (最新)修复了它。

Upgrading to 1.6.2 (latest) fixed it.

我怀疑这个更高版本升级了序列化函数以识别新的HTML5输入类型。

I suspect this later version upgraded the serialize function to recognise the new HTML5 input types.

这篇关于使用HTML5输入类型和jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆