So in my project I have an input, and a div that shows the realtime input value that should emulate the domain name after the model validation clears the white space and replaces it with an underscore. I am wondering if there is anyway I can can do this in my realtime display. I am a bit weak with jQuery and am not too sure how to proceed with this.
this is a Ruby on Rails project.
My current code:
<%= a.label :company_name, "Company Name", class: "label", for: "company_name" %>
<%= a.text_field :company_name, id: "company_name", class: "input"%>
<div class="-mt-4"><span id="domain" class="sm:invisible md:visible text-gray-700 text-xs italic">company_name</span><span class="sm:invisible md:visible text-gray-700 text-xs italic">.loadze.co</span></div>
the jQuery script:
<script>
$('#company_name').keyup(function () {
$('#domain').text($(this).val());
});
</script>
the current script dose work in displaying the value of the input field, but i would really like to show the underscore if a space is inserted.
Any assistance here would be great!