How to prevent form submission when enter key is pressed using jquery.

As a web developer, most of the times you would have to do some functionality / operation before form gets submitted.By default form gets submitted on click of enter key when the input field is focussed.Below code snipppet can be used to avoid default form submision.

$(document).ready(function() {
$(“form”).bind(“keypress”, function(e) {
if (e.keyCode == 13) {
searchFunc($(“#searchInput”).attr(‘value’)); //perform some operation
return false;
}
});
});

How to count the number of lines in the input textarea

Below code snippet helps you to find the number of lines in the input textarea using Jquery & native RegEx functionality.

var textInput = $(“#textareaId”).val();
var lines = textInput .split(/\r|\r\n|\n/);
alert(lines.length);

Plurk gets sudden spurge of traffic due to unexpected free publicity

Plurk could have not asked more than this.
Canadian startup Plurk, a Twitter-like social networking site that has gotten quite popular in China, accused Microsoft China of not only stealing the service’s design, but 80 percent of the service’s code too. In response, Microsoft has pulled its microblogging site, which goes by the name of Juku and was developed by a third-party vendor for the company’s MSN China joint venture.

Plurk has been busy this week, attracting the attention of Social Media evangelists, most who are current Twitter users.This is the best thing that could have happened for plurk due to the outburst.
We are showcasing the few statistical analysis of traffic growth from alexa:
plurk1
plurk2

Plurk saw more than 50% increase in traffic& 200% in alexa traffic rank.

50 Beautiful Free Icon Sets For Your Next Design

Beautiful Free Icon Sets For Your Next Design is on smashing magazine.Go grab it!
…Round-ups of beautiful and useful icons are almost legendary on Smashing Magazine. While some readers complain about the annoying “list”-style of some of our articles, we are confident that useful round-ups of relevant resources are very valuable and useful for designers. This is why over months we collect useful links and then present them in posts in the magazine. Like it or hate it, but the feedback that we get from the design community when we publish such posts is mostly positive which is why we keep doing it.More>>
free-high-quality-icon
Image source:Deviantart
Read More >>

Best CSS Rounded Corner Tutorials

Best CSS Rounded Corner tutorials list are available on the vagrant radio site.
Sometimes creating rounded corners with Css is a big challenge for most designers. Many will end up with a design where they don’t use rounded corners in order to avoid the entire rounded corner kerfuffle that has always been an issue in HTML/ CSS. The question has always been which method or solution is best, and what is the easiest way…..Read more


rounded_corners
Source:Read more

Regular expressions can be a pain. HiFi RegExp tool is designed to help developers learn, practice, and compose regular expressions.

The HiFi RegExp tool is 100% JavaScript using jQuery. This tool was created by New Media Campaigns, the team behind HiFi, a next-generation CMS for web designers, developers, and agencies. Enjoy!

HiFi RegExp tool

Read more & try:

How To: Change default Admin login in Joomla

As you know all new Joomla installations start with a Super Administrator account called, ‘admin’. During the installation process, you will be asked to give this account a password. That’s great as far as it goes, but because the user name of this highly-confidential account is generally well known, 50% of the security of the username/password combination is already exposed. Now all anyone needs to do is guess the password and they’re in.

By changing the user name to something more difficult to guess, you greatly increase the difficulty of accessing the account. An attacker must correctly guess both the user name and password at the same time to gain access. This is several magnitudes more difficult than simply guessing the right password.

Steps to Change the Default admin login

  1. Log into the Back End
  2. Select User Manager
  3. Select the ‘admin’ user record
  4. Change the value in username.
  5. Save
  6. Remember the new username!

How to parse XML data using Jquery

Due to the increase in popularity of Web 2.0 applications and web services it has become increasingly important to be able to parse XML from the client browser.Parsing is not the easiest thing till the JavaScript libraries that supports XML made their way.

With jQuery, when you receive an XML from a callback (usually thro’ Ajax) which is basically a DOM (document object model) that jQuery can traverse seamlessly and efficiently to get the data you need.
we are using jQuery to parse XML due to its ubiquity& for cross browser compatibility.

The below xml file is used for reference.

<?xml version="1.0" encoding="utf-8" ?>
<country>
<state>
<city>Bangalore</city>
<id>24378</id>
</state>
<state>
<city>Chennai</city>
<id>42378</id>
</state>
<state>
<city>Mumbai</city>
<id>324782</id>
</state>
<state>
<city>Hyderabad</city>
<id>6524</id>
</state>
</country>

To parse the xml file we’re going to set up a function that will search each parent element and output the specified child element’s value as text using the find and each statement.The xml data gets parsed on success of ajax callback through parseXml function.Don’t forget to set dataType as “xml” while making an ajax call.
$(this).find(“city”).text() represents the textual value of city by striping the city tags -<city> &</city>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>xml parser using jquery</title>
<script type="text/javascript" src="/jquery-min.1.3.2.js"></script>
<script type="text/javascript">

$(document).ready(function() {
$.ajax({
type: "GET",
url: "/statecity.xml",
dataType: "xml",
success: parseXml
});

function parseXml(xml) {
$(xml).find("state").each(function() {
//Loops through each state & find's respective instance of city & id in the xml file

$("table#Citylist").append('<tr><td>'+ $(this).find("city").text() +'</td><td>'+$(this).find("id").text()+'</td></tr>');

});
}
});
</script>
</head>
<body>
<table id="Citylist">
<tr ><td >City List</td> <td >ID</td><tr>
</table>
</body>
</html>

The output would be displayed as below after parsing the xml file:

The City List ID
Bangalore 24378
Chennai 42378
Mumbai 324782
Hyderabad 6524

How to switch a stylesheet using jQuery.

Switching stylesheets may be necessary to accommodate different screen resolutions, or entirely different look ‘n’ feel of web page .
It really helps in complex styles where more no of styles are included.
Include the following jQuery script to the header section of your HTML file.

<script type="text/javascript">
$(".cssswitch").click(function() {
$(‘link[rel=stylesheet]‘).attr(‘href’ , $(this).attr(‘rel’));
});
</script>

If you are referring your default stylesheet like below :

<link rel="stylesheet" href="greentheme.css" type="text/css">

For switching the styles, just assign the cssswitch class to an HTML element & use the rel attribute to reference the location of your stylesheets.

<a href="#" class="cssswitch" rel="greentheme.css">greentheme</a>
<a href="#" class=" cssswitch " rel="bluetheme.css">bluetheme(new one)</a>

Clicking on the second link above (blue theme) will modify the DOM in such a way that the href attribute will take on the value of bluetheme.css.

5 awesome PSD to XHTML tutorials

1.Coding a Clean & Illustrative Web Design from Scratch

code_illustrative_preview

In this web development tutorial, you’ll learn how to build a web page template from a Photoshop mock-up using HTML/CSS and the jQuery library.

2.Coding a Clean Web 2.0 Style Web Design from Photoshop

image2

In this tutorial thay create a fixed-width web layout using some basic coding techniques. Towards the end, they enhance the design with a bit of jQuery.
This is will teach you how to create the layout in Photoshop, and then how to convert it to a standards-compliant (X)HTML web design.

Read the rest of this entry »