Modified the Regex to accept additional (valid) characters

php
Aadhavan Srinivasan 2 years ago
parent 3b59de608a
commit a7ba5aa8e1

@ -87,7 +87,8 @@ function showPosition(position) {
// /* Flag */
// }
let valid = true;
const domainExp = new RegExp("^http(s)*:\\/\\/[a-zA-Z0-9\\-]+(\\.[a-zA-Z0-9\\-]+)+$");
// const domainExp = new RegExp("^http(s)*:\\/\\/[a-zA-Z0-9\\-]+(\\.[a-zA-Z0-9\\-]+)+[_#]*$");
const domainExp = new RegExp("^http(s)*:\\/\\/[a-zA-Z0-9\\-]+(\\.[a-zA-Z0-9\\-]+)+[\\/_#a-zA-Z0-9\\-]*$");
const filepathExp = new RegExp("^[a-zA-Z]+$");
const glinkExp = new RegExp("^[a-zA-Z]*$");
let glinkStr = glink.value;

@ -50,7 +50,7 @@ if ($is_geo == 1) {
$longitude = doubleval($longitude);
}
$matches = preg_match('/^http(s)*:\\/\\/[a-zA-Z0-9\\-]+(\\.[a-zA-Z0-9\\-]+)+$/',$url);
$matches = preg_match('/^http(s)*:\\/\\/[a-zA-Z0-9\\-]+(\\.[a-zA-Z0-9\\-]+)+[\\/_#a-zA-Z0-9\\-]*$/',$url);
if (($matches == 0) || ($matches == false)) {
printf("The URL entered was invalid. Please try again.");
return;

Loading…
Cancel
Save