Tuesday, June 2, 2009

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

you could also completely remove the field from the DOM
("#myfield").remove();

On Wed, Jun 3, 2009 at 7:40 AM, mkmanning <michaellise@gmail.com> wrote:

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: