Sha256: 4a5adcfd7c3483b0fb0131e7acfd3136e7b176e33b9e6d413279d206fb25f245
Contents?: true
Size: 1.43 KB
Versions: 1788
Compression:
Stored size: 1.43 KB
Contents
<%= pb_rails("passphrase", props: { classname: "pass_input_1" }) %> <%= pb_rails("passphrase", props: { confirmation: true, classname: "pass_input_2"}) %> <div id="match"> </div> <%= javascript_tag do %> window.addEventListener("DOMContentLoaded", () => { const useState = (defaultValue) => { let value = defaultValue; const getValue = () => value const setValue = (newValue) => { return value = newValue } return [getValue, setValue]; } const [input, setInput] = useState('') const [confirmationInput, setConfirmationInput] = useState('') const match = document.querySelector("#match") const input1 = document.querySelector(".pass_input_1").querySelector("input") const input2 = document.querySelector(".pass_input_2").querySelector("input") input1.addEventListener('input', (e) => { setInput(e.target.value) setMatchText() }); input2.addEventListener('input', (e) => { setConfirmationInput(e.target.value) setMatchText() }); const setMatchText = () => { if (input() && confirmationInput()) { if (input() === confirmationInput()) { match.textContent = "They match!" } else { match.textContent = "They don't match!" } } else { match.textContent = "" } } }) <% end %>
Version data entries
1,788 entries across 1,788 versions & 2 rubygems