need help in integrating inline validation!!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pradeepjain
    Contributor
    • Jul 2007
    • 563

    need help in integrating inline validation!!

    I am using a form which does inline validation using jquery!



    and i saw another inline validation method



    i tried to integrate the pop up error which exits in 2nd one to 1st one but failed as i am new to jquery ! Can some one tell me how to do it as the 2nd code is bit complex to me . :(


    Code:
    function validateEmail(){
                    //testing regular expression
                    var a = $("#email").val();
                    var filter = /^[a-zA-Z0-9]+[a-zA-Z0-9_.-]+[a-zA-Z0-9_-]+@[a-zA-Z0-9]+[a-zA-Z0-9.-]+[a-zA-Z0-9]+.[a-z]{2,4}$/;
                    //if it's valid email
                    if(filter.test(a)){
                            email.removeClass("error");
                            emailInfo.text("Valid E-mail please, you will need it to log in!");
                            emailInfo.removeClass("error");
                            return true;
                    }
                    //if it's NOT valid
                    else{
    
                            email.addClass("error");
                            emailInfo.text("Stop cowboy! Type a valid e-mail please :P");
    [B]promptText = "Valid E-mail please, you will need it to log in!";[/B]
    [B]buildPrompt(promptText);[/B]
                            emailInfo.addClass("error");
                            return false;
    
                    }
            }
    If i can make the code something like highlighted bcos already the validation is being done!
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Is there a need for both? One or the other is fine as far as I can see.

    Comment

    • pradeepjain
      Contributor
      • Jul 2007
      • 563

      #3
      I wanted to integrate the second one for ma testing needz!! i did not succeed ! so asked for help :)

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        If you do want to integrate them, in terms of code they both work very differently. For the second one, you need to set special classes which the code looks at to determine the rules to apply. You will also need to set your regex rules in the code (near the top - see the code comments).

        Comment

        Working...