Answers for "javascript regex to match special characters and spaces"

0

javascript regex only letters and spaces

//regex expression:
var reg_name_lastname = /^[a-zA-Z\s]*$/;

//Validation to the user_name input field
if(!reg_name_lastname.test($('#user_name').val())){ //
    alert("Correct your First Name: only letters and spaces.");
    valid = false;
}
Posted by: Guest on December-21-2020
0

how to check for special charaters with spaces javascript

var format = /[ `!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?~]/;
//            ^                                       ^   
document.write(format.test("My@string-with(some%text)") + "<br/>");
document.write(format.test("Mystringwithspaces") + "<br/>");
document.write(format.test("MyStringContainingNoSpecialChars"));
 Run code snippetHide results
Posted by: Guest on January-11-2022

Code answers related to "javascript regex to match special characters and spaces"

Code answers related to "Javascript"

Browse Popular Code Answers by Language