/ Published in: jQuery
regular expression that removes or replaces input text
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
//remove spaces from file name $('input#file_name').val($('input#file_name').val().replace(/ /g,'_')); //replace special chars $('input#file_name').val($('input#file_name').val().replace(/[^a-zA-Z 0-9]+/g,'')); //replace just letters $('input#file_name').val($('input#file_name').val().replace(/[^0-9]+/g,'')); //replace just numbers $('input#file_name').val($('input#file_name').val().replace(/[^a-zA-Z]+/g,'')); //replace single and double quotes $('input#file_name').val($('input#file_name').val().replace(/(\'|\")/g,''));