I've got a form that redirects a user to a dynamic url based on the word they enter. e.g they enter 'banana' and the form takes them to www.domain.com/banana The problem is when somebody enters a word with a dot e.g "banana.apple". Then I get a 404. So I want to replace '.' with '_dot_' or something BEFORE the form is submitted. How do I do it? <form name="openlocation" action=""> <input type="text" name="href" value="" /> <input type="button" value="Go!" onClick="location.href=document.openlocation.href.value;" /> </form> Code (markup): Or course, if there's a sexy htaccess way to do this, then please tell me
<form name="openlocation" action=""> <input type="text" name="href" value="" /> <input type="button" value="Go!" onClick="location.href=document.openlocation.href.value.replace(/\./, '_dot_');" /> </form> Code (markup): maybe something like that.. however i haven't tested it
Thanks! That works perfectly. I should sit down and learn some basic JavaScript one of these days +rep
I think that will only replace the first dot, so "apple.pear.banana." would become "apple_dot_pear.banana." What you want is: value.replace(/\./g, "_dot_"); to make it "apple_dot_pear_dot_banana_dot_"