urgent.. email validation

Discussion in 'ASP General' started by VbUser25, Dec 20, 2004.

  1. VbUser25

    VbUser25 Guest

    Hi

    Please suggest i think i am doing something wrong. I am calling fucntion
    test from another function where i am performing all the validations.I
    want to validate the email id.

    this is the main function where i perform all sort of mandatory
    validation==>
    if (document.f.repemail.value != ""){
    if(test(document.f.repemail.value=false)) {
    alert("Please Enter a valid Email ID!");
    document.f.repemail.focus();
    }
    else {return;}
    }


    Here is fucntion test:
    function test(src)
    { var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
    var regex = new RegExp(emailReg);
    alert(regex.test(src));
    return regex.test(src);
    }
    I am nto getting validated at all!!! where is hte mistake i am doing.
    pls do suggest!

    thanks to those who respond.


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    VbUser25, Dec 20, 2004
    #1
    1. Advertising

  2. You must use / instead of " to enclose your regular expression (and probably
    use \ instead of \\) :

    var emailReg = /^[\w-_\.]*[\w-_\.]\@[\w]\.+[\w]+[\w]$/

    Also, I'm not sure if your regular expression is right for testing all valid
    email addresses. Testing all possibilities for a valid email address is a
    very difficult subject.

    S. L.

    "VbUser25" <> wrote in message
    news:...
    >
    >
    > Hi
    >
    > Please suggest i think i am doing something wrong. I am calling fucntion
    > test from another function where i am performing all the validations.I
    > want to validate the email id.
    >
    > this is the main function where i perform all sort of mandatory
    > validation==>
    > if (document.f.repemail.value != ""){
    > if(test(document.f.repemail.value=false)) {
    > alert("Please Enter a valid Email ID!");
    > document.f.repemail.focus();
    > }
    > else {return;}
    > }
    >
    >
    > Here is fucntion test:
    > function test(src)
    > { var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
    > var regex = new RegExp(emailReg);
    > alert(regex.test(src));
    > return regex.test(src);
    > }
    > I am nto getting validated at all!!! where is hte mistake i am doing.
    > pls do suggest!
    >
    > thanks to those who respond.
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
     
    Sylvain Lafontaine, Dec 20, 2004
    #2
    1. Advertising

  3. VbUser25

    Evertjan. Guest

    VbUser25 wrote on 20 dec 2004 in
    microsoft.public.inetserver.asp.general:

    > Please suggest i think i am doing something wrong. I am calling
    > fucntion test from another function where i am performing all the
    > validations.I want to validate the email id.
    >
    > this is the main function where i perform all sort of mandatory
    > validation==>
    > if (document.f.repemail.value != ""){
    > if(test(document.f.repemail.value=false)) {
    > alert("Please Enter a valid Email ID!");
    > document.f.repemail.focus();
    > }
    > else {return;}
    > }
    >
    >
    > Here is fucntion test:
    > function test(src)
    > { var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
    > var regex = new RegExp(emailReg);
    > alert(regex.test(src));
    > return regex.test(src);
    >}
    > I am nto getting validated at all!!! where is hte mistake i am doing.
    > pls do suggest!
    >


    This is a ASP [serverside] NG.

    > if (document.f.repemail.value != "")


    That's definitely clientside.

    > function test(src)


    could be serverside jscript,

    and if so:
    You cannot call a serverside function from clientside
    else [as suggested by the alert()]:
    Your question is off topic on this NG.

    > thanks to those who respond.


    You're welcome with on topic questions.

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Dec 20, 2004
    #3
  4. VbUser25

    VbUser25 Guest

    thanks a plenty for responding back.

    now i got the error rectified but facing another problem :-( this
    function works well but somehow when i write a@gdhd it accepts it! i
    feel it should search for a "." at least?? am i right in my thots or
    not? if i write a@fhh then it gives the error message!
    here is hte piece of code:
    if (document.f.repemail.value != ""){
    if(!(test(document.f.repemail.value))) {
    alert("Please Enter a valid Email ID!");
    document.f.repemail.focus();
    return;
    }
    }

    function test(src)
    { var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
    var regex = new RegExp(emailReg);
    return regex.test(src);
    }

    pls pls do sugest..i am confused
    thanks



    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    VbUser25, Dec 20, 2004
    #4
  5. As pointed out, this is an ASP (serverside) newsgroup, whereas you seem
    to be posting clientside javascript. If you want help with clientside
    javascript, you should find a more appropriate newsgroup to post to.

    However... if you want to do serverside email validation, check out the
    following two articles:

    "Powerful Form Validation Using ASP"
    http://www.asp101.com/articles/hojjat/formvalidation/default.asp
    This article shows how to check for basic email address requirements.

    "Validating Email Addresses with ASP"
    http://www.asp101.com/articles/hojjat/mxlookup/default.asp
    This article shows how to use freely available websites to do an MX lookup.

    VbUser25 wrote:
    >
    > thanks a plenty for responding back.
    >
    > now i got the error rectified but facing another problem :-( this
    > function works well but somehow when i write a@gdhd it accepts it! i
    > feel it should search for a "." at least?? am i right in my thots or
    > not? if i write a@fhh then it gives the error message!
    > here is hte piece of code:
    > if (document.f.repemail.value != ""){
    > if(!(test(document.f.repemail.value))) {
    > alert("Please Enter a valid Email ID!");
    > document.f.repemail.focus();
    > return;
    > }
    > }
    >
    > function test(src)
    > { var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
    > var regex = new RegExp(emailReg);
    > return regex.test(src);
    > }
    >
    > pls pls do sugest..i am confused
    > thanks
    >
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
     
    Blair Bonnett, Dec 22, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?RGFuaWVs?=

    Any control like email content control? Urgent..

    =?Utf-8?B?RGFuaWVs?=, Oct 6, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    377
    Lucas Tam
    Oct 6, 2005
  2. henry tourneur
    Replies:
    5
    Views:
    4,856
    Steve Pugh
    Dec 23, 2004
  3. Sachin Jagtap

    URGENT !! QUEUE STL PROBLEM URGENT!!

    Sachin Jagtap, Apr 28, 2005, in forum: C++
    Replies:
    4
    Views:
    1,045
    Mark Stijnman
    Apr 29, 2005
  4. Rob
    Replies:
    3
    Views:
    440
  5. Replies:
    1
    Views:
    268
Loading...

Share This Page