Rashid Khan

Rashid Khan

  • NA
  • 159
  • 0

Validation

Dec 6 2009 8:13 AM
Hello.
i am facing a problem in form validation.
i designed few field user name/ password /confirm password /, age and email address.
i create a function in java script.  all text validation is working but email address making problem, i used regex but nothing happen, here is my code
if(EmailId=='')
        {
            alert("Enter Email id");
            document.getElementById("txtEmail").focus();
            return false;
         }
//its working if i leave blank its not allowing but when i type wrong or right email address its say enter correct email
     else
     {
     if(!EmailId.match('/^(\".*\"|[A-Za-z]\w*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z]\w*(\.[A-Za-z]\w*)+)$/'))
        {
            alert("Enter correct Email.");
            document.getElementById("txtEmail").focus();
            return false;
       }
       }
on run time its says enter correct email.
so could you please tell me where i m making a mistake.
and also tell me how can i clear text field when error msg occur nd after clicking ok focus set on tht field

if i m not clear in my query. tell me , i m pooped out
Thanks
Regards
Rashid

Answers (2)