JQuery .submit() changes post data

Posted by ajbeaven on Stack Overflow See other posts from Stack Overflow or by ajbeaven
Published on 2010-05-24T02:06:46Z Indexed on 2010/05/24 2:10 UTC
Read the original article Hit count: 303

I'm posting a form with javascript and it seems to be changing a value that I've entered in.

Html:

<% using (Html.BeginForm("ChangeTime", "Cart", new { cartItemId = cartItem.CartItemID }, FormMethod.Post, null)) { %>
    <%= Html.TextBox("startTime")%>
    <input type="submit" value="Update" />
<% } %>

JQuery:

<script type="text/javascript">
    $('#startTime').change(function() {
        $(this).parent('form').submit();
    });
</script>

When I put a time in the textbox (05/05/2010 06:08 am), the form is submitted, however the string as it comes through, is 05/05/2010 - with the time part removed. I see this in fiddler. If get rid of the javascript and click the button above, it goes through how it should.

Why is JQuery changing my text?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery