Last active
December 15, 2015 20:19
-
-
Save richardsweeney/5317392 to your computer and use it in GitHub Desktop.
Replace foreign letters used in field labels when dynamically creating field names. There's only a few here, these are the ones that are used in scandinavia.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('#acf_fields tr.field_label input.label').live('blur', function() | |
{ | |
var label = $(this); | |
var name = $(this).closest('tr').siblings('tr.field_name').find('input.name'); | |
if(name.val() == '') | |
{ | |
var val = label.val(); | |
var ex = { | |
'ä': 'a', | |
'æ': 'a', | |
'å': 'a', | |
'ö': 'o', | |
'ø': 'o', | |
'é': 'e', | |
'ë': 'e' | |
}; | |
for(letter in ex) { | |
var regex = new RegExp( letter, 'g' ); | |
val = val.replace( regex, ex[letter] ); | |
} | |
val = val.toLowerCase().split(' ').join('_').split('\'').join(''); | |
name.val(val); | |
name.trigger('keyup'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment