Showing posts with label validation. Show all posts
Showing posts with label validation. Show all posts

Wednesday, June 9, 2010

Jquery : Attaching an event to multiple elements at one go

var a = $("#a");
var b = $("#b");
var combined = a.add(b);

Now u can use

combined.click(function () { /* */ });


this can be used in situation where u want to add same validation to two different forms

Thursday, January 22, 2009

Php - how to verify email address entered by user

Php - how to verify email address entered by user

Call the function like this check_email("INFO@google.co.uk"); to do server email validation using PHP

By calling this, function validate the email against the regular expression

<?php
function check_email($mail_address) {
    $pattern = "/^[\w-]+(\.[\w-]+)*@";
    $pattern .= "([0-9a-z][0-9a-z-]*[0-9a-z]\.)+([a-z]{2,4})$/i";
    if (preg_match($pattern, $mail_address)) {
        $parts = explode("@", $mail_address);
        if (checkdnsrr($parts[1], "MX")){
            echo "The e-mail address is valid.";
            // return true;
        } else {
            echo "The e-mail host is not valid.";
            // return false;
        }
    } else {
        echo "The e-mail address contains invalid charcters.";
        // return false;
    }
}
check_email("INFO@google.co.uk");
?>