How to throw Warning dialog on Form Submit?

On a form submit, I would like to throw a warning dialog (Are you
sure? Yes | No - type) but based on the data entered in the form input
fields.

I looked at button_to and link_to but can't seem to make them throw
the dialog based on the data entered in the form?

Any ideas appreciated.

Hari Rajagopal wrote:

On a form submit, I would like to throw a warning dialog (Are you
sure? Yes | No - type) but based on the data entered in the form input
fields.

I looked at button_to and link_to but can't seem to make them throw
the dialog based on the data entered in the form?

Any ideas appreciated.

I think you're getting two different design patterns confused here. A
confirm dialog is just for dangerous operations where you want to make
sure somebody doesn't delete something important just because their
motor skills are not up to par or they didn't understand the label you
chose for that link.

If you want to look at the data and yell at the user based on what they
typed, that is more like a validation in a model, where you would notice
that they just tried to set next year as the year they were born and you
would send them back to the form with an error message.

Please send along some context and maybe we can steer you in the right
direction.

cheers,
jp

It is a reservation form and it has a
start date field and an end date field.

On form submit, I would like a warning to pop up if the span is more
than a week just asking for confirmation from the user since it is not
a common scenario, although it is perfectly ok to allow the user to
reserve for a span more than a week. Hence I am unable to have a
validation in the model.

-Thanks