C# .NET - JavaScript

Asked By Ramendra Kumar
09-Jan-10 12:32 AM
HI, i need a email validator in javaScript, which can able to judge is it a a valid email or not , and he Must Takes this Type Email also rahul.kumar@gmail.com (Means There may be more than 1 dot)

Javascript Email Validation Using Regular Expression  Javascript Email Validation Using Regular Expression

09-Jan-10 12:59 AM

Here's a javascript that you can use to validate an email address, taken from the following link: http://www.freshmango.com/support/kb/web-design-programming/javascript/javascript-email-validation-with-regular-expressions/

<script type="text/javascript">

function validateEmail(){
var emailRegEx = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
str = document.getElementById('emailAddress').value;
if(str.match(emailRegEx)){
document.mailingListForm.submit();
}else{
alert('Please enter a valid email address.');
return false;
}
}
</script>

Regards,
http://www.sql-server-helper.com/faq/data-types-p01.aspx

re  re

09-Jan-10 01:16 AM
<title>Check Email Address</title>
<script language="javascript">
function checkEmail(inputvalue){	
    var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
    if(pattern.test(inputvalue)){         
		alert("true");   
    }else{   
		alert("false"); 
    }
}
</script>
</head><body>
<form name="signupform">
Input your email: <input name="email" type="text" class="inputs" id="email_address"
 value="any@any.com" size="35" maxlength="255">
<input name="summit" type="submit" value="Check" onClick="checkEmail(document.signupform.email.value)">    
</form></body></html>

Re - email validator in javaScript.  Re - email validator in javaScript.

09-Jan-10 01:33 AM
try this good sample code using javascritp allow only (.,@,_,alpha bate).

for example-abc_123.xyz@gmail.com


<script language = "Javascript">
function echeck(str) {

        var at="@"
        var dot="."
        var lat=str.indexOf(at)
        var lstr=str.length
        var ldot=str.indexOf(dot)
        if (str.indexOf(at)==-1){
           alert("Invalid E-mail ID")
           return false
        }

        if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
           alert("Invalid E-mail ID")
           return false
        }

        if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
            alert("Invalid E-mail ID")
            return false
        }

         if (str.indexOf(at,(lat+1))!=-1){
            alert("Invalid E-mail ID")
            return false
         }

         if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
            alert("Invalid E-mail ID")
            return false
         }

         if (str.indexOf(dot,(lat+2))==-1){
            alert("Invalid E-mail ID")
            return false
         }
        
         if (str.indexOf(" ")!=-1){
            alert("Invalid E-mail ID")
            return false
         }

          return true                    
    }

function ValidateForm(){
    var emailID=document.frmSample.txtEmail
    
    if ((emailID.value==null)||(emailID.value=="")){
        alert("Please Enter your Email ID")
        emailID.focus()
        return false
    }
    if (echeck(emailID.value)==false){
        emailID.value=""
        emailID.focus()
        return false
    }
    return true
 }
</script>
re  re
09-Jan-10 10:49 AM

this is the best I found and it works!


function isEmail(string) {
if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
return true;
else
return false;
}


also u can use


 


function verifyEmail(form) {
checkEmail = form.email.value

if ((checkEmail.indexOf('@') < 0) || ((checkEmail.charAt(checkEmail.length-4) != '.') && (checkEmail.charAt(checkEmail.length-3) != '.')))
{alert("You have entered an invalid email address. Please try again.");
form.email.select();
return false;
}

There are more than one scripts that you may require for doing your conventional Javascript validations.  There are more than one scripts that you may require for doing your conventional Javascript validations.
09-Jan-10 10:26 PM
The Javascript website here provides most of the scripts that are needed for these kinds of validations. 

A simple search on the Javascript site gave me http://javascript.internet.com/forms/email-address-validation.html , which does the email validation as you ask. 

Bookmark the site, and you might always like to look at that for all your scripts. And don't forget to provide attribution to the Author and the website.

Hope that helps.
Create New Account
help
What's the go with sql server SQL Server I was just saying today that sql server is full of silly limitations and I seem to hit on a new one every features with more ways to manipulate things than you can poke a stick at. In sql server we don't even have a full range of date functions (a pretty basic feature
migration from SQL Server 2000 to SQL Server 2008 SQL Server I would like to migrate my database SQL Server 2000 to SQL Server 2008. My fronend application is MS Access 2002. I just wanted
Is it possible to use Regular express in Sql server 2005 t-sql? SQL Server I need to extract a pattern .+{:z}-{:i}$ from a varchar column. Thanks, SQL Server Programming Discussions SQL Server 2005 (1) SQL Server 2000 (1) SQL Server (1) Varchar (1) SQLRegex (1) RegExMatch
Rewrite Access SQL for SQL Server SQL Server I've tried unsuccessfully to rewrite this query from Access in a way that SQL Server can interpret it. This is the Access query: [OTHours]+[OTType] / 1000000+NZ([OTRefusal], 0) / 10000000 tblOvertime. OTRoster = tblEmployee.OTRoster, 0.00000001, 0.00000002) Here is what I've tried in SQL Server: [OTHours]+[OTType] / 1000000+[OTRefusal] / 10000000+(CASE WHEN tblEmployee. Overtime = tblEmployee.OTRoster THEN 0.0000001
Operator Precedence in T-Sql SQL Server Between Sql Server 2000 and Sql Server 2005, it looks like operator precedence changed to give multiply / divide higher precedence than unary Does anyone know the reason this was done? Or is there another RDBMS that parses sql that way? It doesn't seem to match the ANSI spec. In fact, I don