Friday, 10 February 2017

JQuery regex validation of e-mail check preg_match

var userinput = $(this).val();
var pattern = /^\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b$/i

if (!pattern.test(userinput)) {
    alert('not a valid e-mail address');
}​

how to check string and number in jquery

var EmailCheck = new RegExp(/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/);

var UsernameVal = document.getElementById('mobileNo').value;

if (!isNaN(parseFloat(UsernameVal)) && isFinite(UsernameVal)) {
    if (UsernameVal.length < 10 || UsernameVal.length > 10 || UsernameVal.length > 11) {
        document.getElementById("errorMsg").innerHTML = "Please Enter 10 Digit Mobile No. ";
        return false;
    }
} else if (!EmailCheck.test(UsernameVal)) {
    document.getElementById("errorMsg").innerHTML = "Please Enter Correct Email";
    return false;
}

Friday, 27 January 2017

How To Use Curl In Php For Json Results From Google Places Api

<?php
$url = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?
location=28.636736,77.27480700000001&radius=5000&types=school&sensor=false&key=YOUR_API_KEY";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_PROXYPORT, 3128);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$response = curl_exec($ch);
curl_close($ch);
$response_a = json_decode($response);
echo $name = $response_a->results[0]->name;
?>