Pages

Wednesday, October 17, 2012

Dynamic tabs using jQuery - why and how to create it

This tutorial will show you how to use jQuery to create tabs that can be added and removed dynamically. Although the example looks bulletproof, there are some questions I will raise about how to use tabs and in which context should they be used in order to make them meaningful and usable.
View demo
When we talk about tabs on web we usually think about tabs used for navigation. However, in this case I'd like to use them in a different context. I want to use them for showing different entities on the same page. By entities I mean anything from plain text to web forms. Actually, I will try to simulate tabs as seen in browsers. Well, at least to some extent. Take Google docs for example, instead of opening each document in a new window (or browser tab), you could open them in page tabs.


Refere following link for more details

http://www.jankoatwarpspeed.com/post/2010/01/26/dynamic-tabs-jquery.aspx
 

Friday, September 28, 2012

Regular expression for finding the special chars present in a given string

<?php
$str = "qdsdasdadsasd\";
$exp ="~@#$%^&*()_+=-[]'\|;  \"  :,./?";

if (preg_match("/[\~@#$%^&*()_+=-\[\]\'|;,.?\/\\\\\\\\]/", $str)) {
    echo "A match was found.";
} else {
    echo "A match was not found.";
}

?>

Thursday, September 20, 2012

Regular expression for allow only numbers and symbols along with one number should be present

var str = "3452.345-345";      
var format =  /^(?=.*\d)[0-9\s\.\-\_\(\)\+]+$/;
            if(!format.test(str)){           
                        alert("Invalid input")               
            } else {
                 alert("Valid input")
            }   

Details

(?=.*\d)     :-   at least one digit should be present
[0-9\s\.\-\_\(\)\+] - given input should be 0 to 9 or symbols like (-_ . space +)

Thursday, September 13, 2012

Regular expression for (Filtering the URLS from a given string)

<?php

// The Regular Expression filter for urls (http://www.sometext.com)
$reg_exUrl = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/";
$text = "The text you want to filter goes here. http://www.google.com";
if(preg_match($reg_exUrl, $text, $url)) {
       echo $url[0];
} else {
    echo "No patterns matched"
}

// The Regular Expression filter for urls (www.sometext.com)
$reg_exUrl = "/(www|WWW|)\.[a-zA-Z0-9\-\.]+\.(com|in|)?/";
$text = 'some texts  http://www.yahoo.in/bin/set/?ilc=37 some texts';
if(preg_match($reg_exUrl, $text, $url)) {
       echo $url[0];
} else {
    echo "No patterns matched"
}
?>

Tuesday, September 4, 2012