0

i wrote a textfield and a submit button with ajax method. The code is belowed:

$form['response']=array(
            '#type'=>'textfield',
            '#size'=>40,
            '#maxlength'=>255,
            '#name'=>$slogannid->nid,
            );


            $form['send_response']=array(
            '#type' => 'submit',
            '#name'=>$slogannid->nid,
            '#value'=>t('Send'),
            '#ajax'=>array(
              'callback'=>'send_response_callback_function',//which will receive a form and form_state as arguments,and return a renderable array
              'wrapper'=>'attach_the_new_comment_'.$slogannid->nid,//The css id of the area to be replaced by the content returned by the #ajax['callback']
              'effect'=>'fade',
              'speed'=>'fast',
              'method'=>'append',
              'event'=>'click',
               ),
            );

My problem is the ajax submit button work. However, when i finished the textfield and press the enter. The form will be sent and refresh the page.

How can i disable the enter event when i finished the textfield?

  • Have you taken a look at the Hide Submit module? drupal.org/project/hide_submit – geekgirlweb Oct 2 '12 at 14:51
  • thx for answer, but i doesn't want to hide submit button. I just want to disable the enter key. – cobenash Oct 3 '12 at 5:20
  • Not sure if you read the features list, it allows the option to disable it and not just hide it. – geekgirlweb Dec 19 '12 at 16:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.