Hi,

I want user to confirm before he submits a form so I added it:

$form['#attributes'] = array('onSubmit' => 'return confirm("Are you sure?");');

FireFox returned "confirm is not a function", in IE8 no error, no prompt. What is wrong here? I checked alert works fine, so onsubmit is triggered.

Also, please suggest if Drupal has a built-in client side (JavaScript) validation library that I can use?

Thanks

Comments

I am learning’s picture

Ah! the problem was my checkbox, I forgot to prefix chk, hence the name was confirm. That cause the problem.

Please suggest if Drupal has a built-in client side (JavaScript) validation library that I can use?

abhishek-anand’s picture

For client side validation use Jquery validation plugin http://docs.jquery.com/Plugins/Validation

This functionality( and many others) are also provided by built in drupal module called http://drupal.org/project/jquery_plugin
it is easy to setup and works out of the box.
To know how to use it http://drupal.org/node/273825

hope this helps :)

Cheers,
Abhishek Anand

I am learning’s picture

Thanks, I'll check as suggested.