mardi 24 janvier 2017

Ruby on Rails: Display confirmation message if not includes

In Ruby on Rails, is it possible to display a confirmation message if the user has not entered a string in a text field? I have a form whereby a user enters text in a text field and want to show a confirmation message if they do not enter a certain string. A simple example could be a text field where users can enter items they want to buy from the shop, such as "bread, potatoes, eggs", and so a confirmation message would appear when they click submit saying "You have not entered milk, are you sure you want to proceed?".

I am have the below code working when a user clicks "destroy", and so wonder if this can be developed to work when a user clicks "submit"?

 <%= link_to 'Destroy', email_path(email), method: :delete, data: { confirm: 'Are you sure?' } %>

Aucun commentaire:

Enregistrer un commentaire