.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> Javascript >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Some Validation through Javascript

Posted By:Athira Sreejith       Posted Date: April 07, 2009    Points: 40    Category: Javascript    URL: http://www.dotnetspark.com  

Below is some useful java script validation for developing web application. this includes Zip code, Email validation, Fax Validation and more
 

Some Validation through Javascript.

Below is some useful javascript validation for developing web application. this includes Zip code, Email validation, Fax Validation and more

Pin/zip validation

  if (FeedbackForm.txtPin.value.length != 0)
  {
   var pinNum = "1234567890"
   var pin = FeedbackForm.txtPin.value
   var found = false;
   for (i=0;i


Phone Number validation

 var phFaxchar = "()-0123456789";
  if (FeedbackForm.txtPhone.value.length != 0)
  {
   var phone = FeedbackForm.txtPhone.value;
   var found = false;
  
   for (i=0;i


Fax Number Validation

  if (FeedbackForm.txtFax.value.length != 0)
  {  
   var Fax = FeedbackForm.txtFax.value;
   var found = false;
   for (i=0;i


Email Validation

if (FeedbackForm.txtEmail1.value.length != 0)
  {
   var str1 = FeedbackForm.txtEmail1.value;      
   if (str1.indexOf('@')<0 || str1.indexOf('.')<0 || (str1.indexOf('.') < str1.indexOf('@')) || (str1.indexOf('.') == str1.indexOf('@')+1))
   {
    alert('Invalid Email id');
    FeedbackForm.txtEmail1.focus();
    return false;
   } 
  }
  if (FeedbackForm.txtEmail2.value.length != 0)
  { 
   var str2 = FeedbackForm.txtEmail2.value;
   if (str2.indexOf('@')<=0 || str2.indexOf('.')<=0 || (str2.indexOf('.') < str2.indexOf('@')) || (str2.indexOf('.') == str2.indexOf('@')+1))
   {
    alert('Invalid Email id');
    FeedbackForm.txtEmail2.focus();
    return false;
   }  
  } 
  return true;
 } 


     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend