ajax textBox-watermark - set a custom default vlaue

SolidSnake@GTI

New Member
i am trying to set a default value for that "TBXinsertDate" \[code\]asp:TextBox\[/code\] control,
by using the \[code\]focus\[/code\] event (\[code\]js\[/code\]) , though... seems to me that the \[code\]ajax watermark Extender\[/code\]actually overrides my action with it's own , if that's the issue , How could i set a default value of my own ? \[code\]<cc1:TextBoxWatermarkExtender ID="insertDate_TextBoxWatermarkExtender" runat="server" TargetControlID="TBXinsertDate" WatermarkText="insertDate" WatermarkCssClass="WaterMarkedTextBox"></cc1:TextBoxWatermarkExtender><cc1:MaskedEditExtender enabled="true" MaskType="Date" ID="insertDate_MaskedEditExtender" runat="server" BehaviorID="tet" TargetControlID="TBXinsertDate" InputDirection="LeftToRight" CultureName="en-GB" UserDateFormat="None" Mask="99/99/9999" MessageValidatorTip="true" OnFocusCssClass="maskedFocus" ErrorTooltipEnabled="true" ErrorTooltipCssClass="toolTipForInvalid"></cc1:MaskedEditExtender><asp:TextBox ID="TBXinsertDate" runat="server" ToolTip="please insert date" Width="76px"> </asp:TextBox>\[/code\]and I know, I could use datePicker ... of any kind , but the requirements are as in question , set it manually via keyboard.updatedefault should be todays datem,like...26/12/2012Update #2 Code Javascript+Ajax dual Mode WaterMark\[code\] var masked = "__/__/____"; var MultiWatermark = function (obj, options) { var defaultOptions = { // These variables can be changed to alter functionality using the passed in options object watermarkVals: ["insert date", "mmddyyyy"], // all watermark values. totalIterations: 20, // how many times to go through watermark Array. watermarkClassName: "WaterMarkedTextBox", normalClassName: "NormalTextBox", changeDelay: 1000, // in milliseconds extraValsToCheck: ['', null]// } //merge options with defaultOptions for (var property in defaultOptions) { if (!options.hasOwnProperty(property)) { options[property] = defaultOptions[property]; } } // local variables (do not change) var textBox = obj; var iterationCounter = 0; var itemCounter = 0; var intrId; var startWatermark = function () { itemCounter = 0; iterationCounter = 0; // resets for after blur intrId = setInterval(function () { alterWaterMark() }, options.changeDelay); } var stopWatermark = function () { clearInterval(intrId); } var alterWaterMark = function () { if (iterationCounter < options.totalIterations) { textBox.value = http://stackoverflow.com/questions/14042420/options.watermarkVals[itemCounter]; itemCounter += 1; if (itemCounter == options.watermarkVals.length) { itemCounter = 0; iterationCounter += 1; } } else { stopWatermark(); } } var isWatermarkValue = function (val) { var i = options.watermarkVals.length; while (i--) { if (options.watermarkVals === val) { return true; } } // value is not in watermark array, so check secondary values. i = options.extraValsToCheck.length; while (i--) { if (options.extraValsToCheck === val) { return true; } } } var setClass = function () { textBox.className = isWatermarkValue(textBox.value) ? options.watermarkClassName : options.normalClassName; ///////this is wher i tried to set it <========== textBox.value ="26/12/2012"; } var focusEvent = function () { stopWatermark(); if (isWatermarkValue(textBox.value)) { textBox.valuehttp://stackoverflow.com/questions/14042420/= ""; ///////this is where i was First time trying to set it <========== //alert("was focused"); } setClass() } var blurEvent = function () { if (isWatermarkValue(textBox.value)) { startWatermark(); } setClass(); } var initWatermark = function () { setClass(); textBox.onfocus = focusEvent; textBox.onblur = blurEvent; startWatermark(); } initWatermark(); } function runWatermarkOn(formId, targetid, wm1,wm2,wm3, iterations, delay) { var dateOptions = { // These variables alter functionality, the main script will use the defaults of any options not included here watermarkVals: [wm1, wm2], // all watermark values. totalIterations: iterations, changeDelay: delay, // in milliseconds extraValsToCheck: ['', null, masked] } if (wm3!= undefined) dateOptions.watermarkVals[2] = arguments[4]; new MultiWatermark(document.forms[formId].elements[targetid], dateOptions); } runWatermarkOn("form1", "TBXinsertDate", "insert Date", "dd/mm/yyyy", undefined, 2, 1500);\[/code\]please See Comment in middle of Code block above . that's where i was trying it.tried hardcoding todays date as it's value.
 
Back
Top