By I am learning on
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
Ah! the problem was my
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?
Jquery Validate
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
Thanks, I'll check as
Thanks, I'll check as suggested.