July 13th in Javascript by pbu .

how to strip special characters with jQuery form validation!

JQuery form validation – How to remove special characters!

i was using a jquery form validation plugin and it was so easy in validating a form. I was stuck in a scenario where i want users to register userID and i dont want them to enter special characters like dots and just want them to enter alphabets, number and underscore in the username.

I went through the documentation of the plugin and there was no such methods to strip the special …

July 12th in Javascript by pbu .

how to reload/refresh a page with jquery?

how to reload/refresh a page with jquery?

Its very simple.

Lets say you have a button refresh all, which basically does reloading the page when you click it. Here is the code

// use location.reload() in jquery to reload a page within onclick
<input name="doRefresh" type="button" id="doRefresh"
value="Refresh All" onClick="location.reload();">

July 12th in Javascript by pbu .

Fix-> JQuery onclick browser jumps to top of page!

JQuery onclick jumps to top of page

i had an issue with jquery code where i have a html link doing specific tasks for onclick event. Since the appear on bottom of my page, when i click on the link the browser jumps to top of the page every time i click.

<a href="#" onclick="dofunct()">click me</a>

This is really very frustrating as everytime i click a link, the browser jumps to top of page. After a long search, i fixed the problem by …

July 12th in Javascript by pbu .

how to call a php script from javascript?

how to call a php script from javascript?

I have always wondered how to call a php script and send GET data from javascript code. It was very important for me as in many projects i have worked i never wanted to header redirect to original php page after delete, edit operations which is really a mess.

jQuery has revolutionized the way we look at javascript and it has certainly bridged the javascript(client side) and php (server side).

so how do you …

July 9th in Games by pbu .

Wheelman is another GTA like game! WOW

Wheelman is another GTA like game!

Wheelman ROCKS! It is high flying, action packed GTA like racing game and i can say WOW! The game has great graphics and creators of the game brought in such a innovation in action racing like melee, air jacking and precision aiming. Awesome! I havent seen that before!

The game goes on like you will be in barcelona and taking on gang leaders one by one with number of missions. The part i liked most …

July 6th in PHP Scripts by pbu .

PHP script using mail() vs smtp?

PHP script using mail vs smtp method for emailing

I have often confused about the which method to use for sending mails with a php script. I have used php mail() function in many projects and it is often slow, which is because this function opens sockets everytime you call this function. This doesnt work if you are mass emailing and smtp or sendmail is the way to go.

The best and fast way of sending email is using

- SMTP (faster)
- …

July 2nd in Javascript by pbu .

how to check if image loaded or not in javascript?

how to check if image loaded or not in javascript?

If you are having a webpage with large sized images, you would notice the browser taking long time to load those images and showup. A good idea would be show a loading animation until large photos load.

There is a way to check whether the images have been loaded or not in javascript. Using the Image() object is a good method to cache large images.

You can use onload function to trigger a …

July 2nd in Javascript by pbu .

how to change div content in javascript?

how to change div content in javascript?

Its very easy to change the contents of div in javascript. Just get the object of div using getElemementbyID() or getElementbyName() and use innerHTML property with the new value.

divObj = document. getElementbyID("mydiv");
divObj.innerHTML = ‘<p>This is a html code</p>’;

One important thing to note is, your div should have loaded after all the images. If not it wont work.

June 23rd in PHP Scripts by pbu .

PHP script to convert text string to image

PHP script to write email address into a image

I was after a php script that dynamically converts text to image and finally i decided to code on my own. It also does convert small length text to image like names, emails etc..

This script automatically calculates the width of text into pixels inserts the PNG or gif image.

this is a string to <
>

To call the script for dynamically generating an image just use the html code

<img src="txt2img.php?text=<? echo $str ?>" …

June 18th in Linux/Unix by pbu .

how to change hostname in linux centos?

how to change hostname in linux

Very often you might want to change the hostname in your linux server. The hostnames are usually written like…

vps.domain.com
server.domain.com
box.domain.com
web.domain.com

and it is a very good idea to follow this hostname format.

To change hostname all you have to do is modify 2 files

1. Open /etc/hosts and change the name of the host

127.0.0.1 vps.domain.com vps localhost localhost.localdomain

2. Open /etc/sysconfig/network and do the change

HOSTNAME=”vps.domain.com”

Once this is done, check whether the hostname has been changed using hostname command after …