I have a button element in form builder as follows
$form['fieldset']['add_new_event_btn'] = array(
'#value' => t('Add new event trigger'),
'#type' => 'button',
'#attributes' => array(
'style' => 'margin-top:20px;width:200px;margin-right:275px;float:right',
),
'#ajax' => array(
// Function to call when event on form element triggered.
'callback' => '::enable_event_trigger',
// Effect when replacing content. Options: 'none' (default), 'slide', 'fade'.
'effect' => 'fade',
// Javascript event to trigger Ajax. Currently for: 'onchange'.
'event' => 'click',
'progress' => array(
// Graphic shown to indicate ajax. Options: 'throbber' (default), 'bar'.
'type' => 'throbber',
// Message to show along progress graphic. Default: 'Please wait...'.
'message' => 'loading',
),
),
);
But this button is act as the submit button , and there for the validation for other elements works and shows the error message on the next reload when i leave the page as it is, How can i rectify this problem ??