Tuesday, June 2, 2009

[jQuery] Re: How to prevent a particular field being submitted in form submission

To set the value of a form field, use this:

$("#myFieldId").val("")

To do this without setting the field to an empty value, modify your
original approach:

$("#MyForm").submit(function(){
var params = $(this).serializeArray();
$.post('/register.php',
$(params).filter(function(){
return this.name != "data[User][passwd]";
}),
callback,
"json"
);
return false;
});

On Jun 2, 7:17 pm, Clare <little.miss.miracle.g...@gmail.com> wrote:
> I tried disabing the field, but unfortunately no respose from the
> server in ajax call.
> $("#myFieldId").attr({value:""}) works fine.
> Is there any way to do this without resetting the field value?

No comments: