Posts Tagged ‘JavaScript’

Even though, it is always recommended to use TextBoxWatermark control which is supplied by Ajax Control Toolkit, there are some other ways to incorporate the same behavior while using JavaScripts and jQuery.

This is an illustration of using a water mark text in a textbox control while using only 2 simple JavaScripts (OnBlur and OnFocus events).

This is how it looks like,

Enter Something…” is the configured watermark text which is to disappear when the cursor is on the textbox or when a specific text (“Hi…”) is used.

Cursor is there on the textbox (OnFocus),

(more…)

Before overriding…

After overriden…

Simple overridden function implementation

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” ““>http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”&gt;

<html xmlns=”http://www.w3.org/1999/xhtml” >

<head>

<title>Untitled Page</title>

<script type=”text/javascript” language=”javascript”>

// When a window.confirm() is called, it is overriden by CustomConfirm().

if (document.getElementById) {

window.confirm = function (mess, title, okBtnText, cancelBtnText, iconType) {

return CustomConfirm(mess, title, okBtnText, cancelBtnText, iconType);

}

}

(more…)