Using HTML5 input types and jQuery

2020-04-07 19:32发布

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" />

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();

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

Using jquery 1.6.0

1条回答
我欲成王,谁敢阻挡
2楼-- · 2020-04-07 19:53

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

Upgrading to 1.6.2 (latest) fixed it.

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

查看更多
登录 后发表回答