About oninput in phoenix html form

hi everyone.I learning elixir and phoenix.thanks in advance.

the code in oninput is for validating key input for number only.its does not work.why?

  <%= text_input f, :spent, maxlength: "2", size: "2", oninput: "this.value=this.value.replace(/(?![0-9]|\.)./gmi,'')" %>

this one working but i had no idea how to bind it to the :spent

<input class="text-xl" maxlength="2" size="2" oninput="this.value=this.value.replace(/(?![0-9]|\.)./gmi,'')"></input>

this code in .leex