"If at first you don't succeed; call it version 1.0" :-Unknown

Pages

Wednesday, July 14, 2010

Prevent Users from Selecting Weekends using jQuery UI DatePicker

 Hi friends,
Not known to many, jQuery UI DatePicker has a built-in function called 'noWeekends', that prevents users from selecting weekends, by disabling them.

Here’s how to use it

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <link rel="Stylesheet" type="text/css" href="http://ajax.googleapis.
com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" />
    <script  type="text/javascript" src="http://ajax.microsoft.com/ajax/
jquery/jquery-1.4.2.min.js"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/
libs/jqueryui/1.8.2/jquery-ui.min.js"></script>


    <script type="text/javascript">
        $(function() {
            $("#datepic").datepicker(
            { beforeShowDay: $.datepicker.noWeekends }
            );
        });
    </script>
</head>
<body>
  <input id="datepic"/>
</body>
</html>
 
it's very use full 'n simple ,i hope it helps u some way 
 
Have a nice day... 'N happy Coding :)

 jQuery in Action, Second EditionjQuery Cookbook: Solutions & Examples for jQuery Developers (Animal Guide)Learning jQuery 1.3

Tuesday, July 13, 2010

Disable JavaScript on browsers running IE6 or Lesser

 Hi friends,
Web Developers often face requirements to detect the browser type and version and execute some script based on that. If you are not using any JavaScript framework, then here’s how to execute a script only if the Internet Explorer version is greater than 6 (IE6)
Just add this piece of code in between the ‘head’ tags

<head>
<title>Execute script only if > IE 6</title>
<!--[if gte IE 7]>
<SCRIPT LANGUAGE="Javascript">
alert("You are running Internet Explorer 7 or greater");
</SCRIPT>
<![endif]-->
</head>
 
This is how Microsoft officially recommends you to detect the browser type and version. As stated in the documentation,
“The downlevel-hidden conditional comment contains hyphens ("--") in the opening and closing tag, similar to the basic HTML Comment. The content is placed inside the comment tags. Because the first four characters and the last three characters of the comment are identical to a basic HTML Comment element, down-level browsers ignore the HTML content inside the comment block”

HTML5: Up and RunningHTML5: Designing Rich Internet Applications (Visualizing the Web)Beginning HTML5 and CSS3: Next Generation Web Standards 

Tuesday, July 6, 2010

pre-text on texbox or watermark on textbox without using ajax

Hi friends,
pre-text in texbox is very much common on web pages. i seen so many web pages using Ajax and jquery for this stuff.But i have simple one where i'm using only the client side event of the textbox. onFocus, onBlur.

DEMO



Description
i'm passing the pretext on the time i initialize the txtbox and on onfocus event i'm i make the value to empty and onBlur event i check the value if it is null i make the value to my pre-text :). it's done by a simple if else statement
code 

 <td ><input name="Firstname" type="text" class="text" id="email" onFocus="if (this.value=='Firstname'){this.value='';};return false;" onBlur="if (this.value==''){this.value='Firstname';return false;}" value="Firstname" size="15"></td>

JavaScript: The Good PartsJavaScript: The Definitive GuideObject-Oriented JavaScript: Create scalable, reusable high-quality JavaScript applications and libraries