Hey,
I am looking for a way to generate a valid tag (string with only a-z and minus as valid chars) out of a given string.
Just let me show you the code:
<p>
<label>Tag Title *:</label>
<input type="text" class="tag_title" name="input_tag_title" value="" />
</p>
<p>
<label>Tag (A-Z; -) *:</label>
<input type="text" class="tag" name="input_tag" value="" />
</p>
As soon as Tag title looses focus, the Tag input box shall be filled with a valid string. It should only contain characters a-z (regardless of case) and a minus. But this should only take place if the tag-input is empty. If it is not empty, the entered string (in the tag input field) shall be checked for invalid chars and automatically replace all non-valid characters (replace all non-alphabetical characters with minuses).
I tried it with
$(".tag_title").blur(
function()
{
$(".tag").text = this.value.replace(/[^a-z\-]/g, '_');
}
);
But that does not work. Any hints?
Thanks!