White Space Problem with JavaScript

October 31st, 2009 by dr.emi

This tutorial will explain about how to solve white space problem with JavaScript. One time, I founded bug on my PHP script. White space was broke it! Shit!. However javascript doesn’t have trim function like PHP. For example, if you want to validate user form using jQuery and PHP, my advice is: you must check the white spaces before send string to PHP Action Script. Then you will fine to use PHP trim function or class defined.

It’s fuck’n crazy. My jQuery not respond If I don’t check white space before send string into PHP script. So I need to find the white space before send it!

Here are my simple javascript code to find and count the white spaces:

// Count the number of times a substring is in a string.
String.prototype.substrCount =
  function(s) {
    return this.length && s ? (this.split(s)).length - 1 : 0;
  };

//some function to implementad
function loadContentResult(id) {
	if(id.substrCount(' ') > 0)
	{
		window.alert('I found white spaces on field');
	}
       else
       {
		window.alert('White spaces cleared!! You may add the next PHP / jQuery here');
       }

First: counting white space as problem caused

String.prototype.substrCount =
  function(s) {
    return this.length && s ? (this.split(s)).length - 1 : 0;
  };

Next, we will try the scripts as user id validator on my jQuery tutorial. See you!

Popularity: 38% [?]

Website Web Development dan Design dremi.NET Telah Publish

October 27th, 2009 by dr.emi

Malam ini guwe sempet juga nulis di blog kesayangan ini :)

Lama sudah tutorial kagak diupdate. Karena sesuatu dan lain hal, kadang guwe cuma bisa approve komentar dowank. Ya, bagaimanapun waktu sudah berubah. Saat ini sudah banyak para aktifis / blogger-bolgger muda di dunia maya yang telah berkarya dan sharing dengan rajinnya. Mengharapkan rating, publikasi, dan dikenal banyak orang :) semoga yang diatas memberikan balasan terbaik buwat kalian semua yang rajin berbagi :)

read more

 

Popularity: 2% [?]

Kerja Keras Adalah Energi Kita

October 24th, 2009 by dr.emi

Pertamina

Kerja Keras Adalah Energi Kita!!
Memang benar, kalimat ini sempat menghentakkan hati kecilku! Bagaimana tidak, sebuah kalimat dengan makna yang senantiasa melekat di jiwaku sejak awal berkarir di luar daerah, telah banyak memberikan kemudahan dalam menjalankan setiap pekerjaanku.

read more

 

Popularity: 1% [?]

Password Founded for GnomePM.XLS

October 8th, 2009 by dr.emi

Password founded for GnomePM.xls from Civil and Environment Departement of ITB Bandung. GnomePM Application is simple XLS file that build in Macro and Visual Basic. With GnomePM, you can manage Construction Project in Worksheet are.

As you read on this link, GnomePM was last updated in 17/09/2007

http://si.itb.ac.id/~abduh/GnomePM/download.html

Contact me to get password list! and unprotected GnomePM.xls

Popularity: 15% [?]

Download PHP Script: Backup and Restore Database

October 1st, 2009 by dr.emi

Hi guys!

This is PHP Script to backup or restore your SQL Database. It’s Free to download!

Just visit my PHPClasses Page:
http://www.phpclasses.org/browse/package/5720.html

Or let’s discuss about something bug or report on:
http://www.phpclasses.org/discuss/package/5720/

Popularity: 26% [?]

 
 
 
 
Category
stack