When someone puts their email or url in the single input text field. The input will know which action to use whether to email or target blank the url. thanks
I’m not sure I fully understand the question. I’m assuming this is for Rails?
So you have a textfield where someone could enter either a URL or email address, and then based on what it is you want to generate the correct link?
You’d need to figure out a conditional that determines whether something is a URL or email address and then render it accordingly.
For example something like:
This isn’t perfect because URLs could have @-signs in them, but you can use a method meant to check whether something is a correct URL/email. A simple Google search will return many results.
yes its for rails and yes i want to generate the correct link! right now i have two separate textfields --> it under one div <div>
<%= mail_to 'email', @post.email %>
<%= link_to 'website', @post.email %> </div> . Ah okay I'll look into it. Thanks WIPGod!
I figured it out :)
👋 Join WIP to participate