Reputation: 2938
I got the following problem and I did not find any solution.
I have to input fields: "label" and "url".
When you write something into the label field it should be duplicated into the url field. This works like a charm, but I need the url field to be (url_encoded or sanitized) rather it would like to replace special characters with customized ones e.g. 'ä' with 'ae' or ' ' with '+'. I figured I could just use a RegEx function to replace things like ä or é but I do not get it right.
Can you tell me how I can do it?
Thanks in advance.
Upvotes: 1
Views: 543
Reputation: 2164
var h = function(){
var self = this;
setTimeout(function(){ $("#url").val(encodeURIComponent($(self).val())); }, 5);
};
$("#label").change(h).keydown(h);
Upvotes: 1