Below is the code I am using to validate a string using regular expressions (RegEx
):
if(!this.validate(this.form.get('Id').value)) {
this.showErrorStatus('Enter valid ID');
return;
}
validate(id) {
var patt = new RegExp("^[a-zA-Z0-9.]{1,}$");
return patt.test(id);
}
The following strings should be accepted:
santosh.jadi
santosh.jadi.others
The following strings should not be accepted:
.santosh.jadi
santosh.jadi.
santosh..jadi
Can someone please explain to me what I might be missing?