mercredi 13 octobre 2021

Call Ajax if inputs are filled

I have two inputs, should call ajax when both are filled

<div class="col-md-6 col-xs-6"><%= form_input :first_name, wrapper: :default_form %></div>
<div class="col-md-6 col-xs-6"><%= form.input :last_name, wrapper: :default_form %></div>

I would like to verify if exists some users with first and last name equals

def verify_duplicate_user
 user = User.where('first_name LIKE ? AND last_name', "%#{params}%", "%#{params}%")
 true if user.size.positive?
end

How to use ajax in this case and open a modal if verify_duplicate_user returns some record

Aucun commentaire:

Enregistrer un commentaire