- <script language = "javascript" >
- function checkEmail() {
- var email = document.getElementById('txtEmail');
- var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
- if (!filter.test(email.value)) {
- alert('Please provide a valid email address');
- email.focus;
- return false;
- }
- }
- < /script>
Take a textbox and button in your aspx page and call the JavaScript function on button click.
- <input type='text' id='txtEmail'/>
- <input type='submit' name='submit' onclick='Javascript:checkEmail();'/>