Created
November 29, 2019 07:20
-
-
Save prashant1k99/a342f7bf4364fd84af58e2242ddbb6a1 to your computer and use it in GitHub Desktop.
Using RegExp in JS
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
//RegExp for URL validation - ^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$ | |
let exp = ^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$; | |
function testInfo(phoneInput) { | |
var OK = exp.exec(phoneInput.value); | |
if (!OK) | |
window.alert(phoneInput.value + ' isn\'t a phone number with area code!'); | |
else | |
window.alert('Thanks, your phone number is ' + OK[0]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment