Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery-Mask-Plugin to mask email addresses and web URL's

I'm using the jQuery-Mask-Plugin in my application and using that I was able to successfully add masks to telephone numbers, date time .. etc.

$("#date").mask("99/99/9999",{placeholder:"mm/dd/yyyy"});
$("#phone").mask("(999) 999-9999");

But I could not find a way to add masks to email addresses and web site addresses.

I know it is some what tricky to identify exact patterns in those but is there any way in jQuery-Mask-Plugin to do that ?

like image 237
prime Avatar asked Feb 28 '15 09:02

prime


1 Answers

There is no such thing as e-mail "mask" because it doesn't have a "fixed" or predictable structure. First, you need to validate your input, always, and that can be done with a simple regexp. Now.. If you want to avoid the user typing things that shouldn't be done you can do this:

$('.alpha-no-spaces').mask("A", {
	translation: {
		"A": { pattern: /[\w@\-.+]/, recursive: true }
	}
});

Hope it helps.

like image 185
Igor Escobar Avatar answered Oct 24 '22 18:10

Igor Escobar