| Kenny Smith 2006-01-27, 8:48 pm |
| For those of you struggling with field exit, here is a way to implement
it with JavaScript. On your widget for the input field, click the
properties. For the 'Style' option, enter the following:
" onblur="fieldExit(this,4)"
The first quotation mark terminates the style element while creating the
onblur attribute for the HTML element. Next, add the javascript
function. I always recommend putting your JavaScript in js library. Here
is the function:
function fieldExit(field, fullLength){
var val = trim(field.value);
var missing = fullLength-val.length;
for(x=0;x<missing;x++){
val='0'+val;
}
field.value=val;
}
The fullLength variable is the maximum length of the field that you are
trying to field exit. Finally, if you have created a submit button (for
the [enter] event), add javascript for an onclick event to move the
cursor position out of the last field, to ensure the field exit function
fires.
Here is an example. The first argument of setCursorPosition is the
absolute cursor position.
<a name="[enter]" class="HostKeyLink" accesskey="HATSForm"
href="java script:ms('[enter]','hatsportletid')"
onclick="setCursorPosition(596, 'HATSForm');">Search</a>
|