# Add Javascript to :confirm in form submit

**URL:** <https://www.ruby-forum.com/t/add-javascript-to-confirm-in-form-submit/120881>\
**Category:** Rails\
**Created:** [November 21, 2007, 12:46pm UTC](https://www.ruby-forum.com/t/add-javascript-to-confirm-in-form-submit/120881 "2007-11-21T12:46:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![helzer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/e19b73/32.png) [@helzer](https://www.ruby-forum.com/u/helzer)\
**Post date:** [November 21, 2007, 12:46pm UTC](https://www.ruby-forum.com/t/add-javascript-to-confirm-in-form-submit/120881/1 "2007-11-21T12:46:55Z")

</div>

I want to have some logic in my :confirm message, so that if the user  
enters some illegal data, it will notify directly when clicking on  
submit, and doesn’t have to go through the server.

How can I add my Javascript code to the Rails :confirm attribute?

Can I do that with AJAX forms?

Thanks,  
Helzer
