Archive for the 'JavaScript' Category



How to get url with Jquery and PHP

current URL in address bar
PHP
$pageURL= $pageURL= $_SERVER["REQUEST_URI"].$_SERVER["REQUEST_URI"];
Jquery
$(document).ready(function() {
var pathname = window.location.pathname;
alert (pathname);
});

Jquery Image area select Z-index issue

If you try using PHP & jQuery image upload and crop [http://www.webmotionuk.co.uk/php-jquery-image-upload-and-crop/]
with some sort of modal like popup functionality, you will notice that the imgareaselect selection does not have proper zindex value,
although this plugin is using 0.6 version and 0.8/0.9 claims to have added zindex option, still doesnt seem to work
so grab 0.6 from link [...]

If you need to add several emails, to refer a friend without asking the user to add all in separated by commas !
Code below provides separate field, where user can add individual email and press ADD, emails are then added automatically, separated by a comma “,” . There is an extra comma at the end [...]

PHP
<?php
$pattern = "/^(083|086|085|086|087)\d{7}$/";
$phone = "087343266";

if (preg_match($pattern,$phone)) echo "Match";
else echo "Not match";
Jquery
$.validator.addMethod("phoneNumber", function(value, element) {
        return /^(083|086|085|086|087)\d{7}$/.test(value);}, "   Not Valid");

$(document).ready(function(){
    $("#reg").validate({
 rules: {
     mobile:{required:true,
    number:true,
    minlength:10,
    phoneNumber:true
    }},