I am trying to get 2 functions to validate an SSID and WPA2 passcode.
function isValidSSID(ssid) {
return (regex)
}
and
function isValidWPA(passcode) {
return (regex)
}
I was hoping to find a regex for each...
I was looking for what are valid characters for each:
The SSID can consist of up to 32 alphanumeric, case-sensitive, characters. The first character cannot be the !, #, or ; character. The +, ], /, ", TAB, and trailing spaces are invalid characters for SSIDs.
WPA: https://superuser.com/questions/223513/what-are-the-technical-requirements-for-a-wpa-psk-passphrase
Thanks, Don
Update:
the SSID function that worked for me:
function isValidSSID(str) { return /^[!#;].|[+\[\]/"\t\s].*$/.test(str); }
I used the site https://regex101.com/r/ddZ9zc/2/
the WPA function that worked for me:
function isValidWPA(str) { return /^[\u0020-\u007e\u00a0-\u00ff]*$/.test(str); }
Regular expression for all printable characters in JavaScript
I did the length check elsewhere in javascript.
Thanks!