简体   繁体   中英

Drupal7:Prevent image from uploading by pressing other ajax button

I have created a form through structure in backened 1. field_dimensions from physcial module. 2. then added image field field_image 3. through form_alter added ajax button. below mention

      $form['getquote_fs']['getquote']['get-quote-btn'] = array(
    '#type' => 'button',
    '#name' => 'estimate',
    '#button_type' => 'button',
    '#executes_submit_handler' => false,
    '#limit_validation_errors' => array(array('field_dimensions')),
    '#size' => 5,
    '#weight' => 100,
    '#default_value' => '<span class="bold sd-red">get</span> <span class="normal sd-orange">estimate</span>',
    '#maxlength' => 5,
    '#description' => t('an industry estimate of how much would I pay.'),
    '#ajax' => array(
        'callback' => 'custom_startrack_ajax_cal',
        'method' => 'replace',
        'prevent'=> 'sumbit',
     ),

  );

Now when inside the form if I browse image and press either of the other ajax button.Its directly uploading the image.How i can remove it from being uploading in folder

you can disable the behavior of buttons easily with jquery.

try one of these:

$("#your-button-id").submit(function(e){
   return false;
});

or

$("#your-button-id").submit(function(e){
    e.preventDefault();
 });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM