Hi,

I am very new in drupal. I have to create a form using ajax and javascript in drupal. I have created the form using content types and managed fields. But I cant create submit and cancel button. Anybody know how to develop a simple add form with javascript validation and also ajax implementation. I dont prefer webform. Excluding that, give me some other idea to create a complete form using module. Please help me. I cant move further .

Thanks & Regards,
S.Sujatha

Comments

maori’s picture

hiya

not sure how to do it with javascript but there is a function called validate which may help

for example

function test_form_validate($form_id, &$form_state) {
 $name = $form_state['values']['your form element'];
  if (!$name)
 {
  form_set_error('your form element', t('must choose a catergory'));
 }
}

where test == your module name
and 'your form element' == the form item you need to validated

also i think another way to do this is add the required to your form element like so

 $form['first_name'] = array(
    '#type' => 'textfield',
    '#title' => t('name'),
    '#required' => TRUE,
      '#default_value' =>  $user->name,
      '#size' => 15,
  );

I'am new aswell and still on the learning curve but i think i have above correct i'am sure someone with greater knowledge will be able answer in more detail

regards

rightchoice2c_me’s picture