This code can be used in other technologies too.
Example:
mine.html
<input type="text" class="email form-control" placeholder="E-Mail" value="{{currentUser.profile.details.email}}">
mine.js
if ( $('.email').val().length > 0 ){ if(!/^[a-zA-Z0-9][a-zA-Z0-9\._-]+@([a-zA-Z0-9\._-]+\.)[a-zA-Z-0-9]{2}/.test($('.email').val())) { alert("Please enter a valid email."); } }