Confirm box depending on input value

I'm very new to javascript so don't judge hard (any suggestions or
comments would be highly appreciated).

I have a form in my rails app (haml file):

= simple_form_for(@book, remote: true) do |f|
    = f.input :book_title, as: :string, label: "Title of a book"
    = f.input :pages_number, as: :string, label: "Number of pages"
    = f.button :submit, "Create", class: "btn btn-success"
    = link_to t('buttons.cancel'), '#', onclick: "$.modal.close()",
class: 'btn btn-warning pull-right'

The action in controller which opens a form:

  def new
    @book =

The action in controller which saves a form:

  def create

What I'm trying to do is check whether input number of pages is bigger
than 10. I want to create a confirm box.

I was trying to save @pages_number = params[:pages_number] in create
action, and use data: (@pages_number < 10 ? { confirm: "Are you sure?" }
: nil) in the view, but it didn't work.

Do I need to use Javascript in this case?