Saravanan K wrote:
Hi,
I am having a problem with right click option with Netscape 4.7. I
am unable to make the Text field read-only using the Onfocus =
"this.blur()" but user is able to use the right click option which
will open the edit menu (popup menu) and he is able to cut, copy paste
options.
Please send me solution for this.
There is none. The user can always change the value in a visible input in
Netscape 4.7. They can disable client-side JavaScript and change the
value. They can type
"javascript
:void(document.forms['formname'].elements['elementname'].value='theirValue');"
in the address bar.
You can attempt to circumvent the user changing the value of an input with
something like:
<form>
<input type="text"
name="input1"
value="This is a test"
onchange="this.value=this.form.elements[this.name + 'Hidden'].value;"
onfocus="this.blur();"
readonly="readonly">
<input type="hidden"
name="input1Hidden"
value="This is a test">
</form>
Or:
<body onload="rememberTextValues();">
<script type="text/javascript">
function rememberTextValues() {
var f, el;
if (f = document.forms) {
var ii = f.length;
while (ii-- > 0) {
if (el = f[ii].elements) {
var jj = el.length;
while (jj-- > 0) {
if (el[jj].type == 'text') {
el[jj].originalValue = el[jj].value;
}
}
}
}
}
}
</script>
<form>
<input type="text"
name="input1"
value="This is a test"
onchange="this.value=this.originalValue;"
onfocus="this.blur();"
readonly="readonly">
</form>
But when all is said and done, you _must_ _must_ _must_ validate the value
of inputs after they are submitted to the server. In other words, don't
trust that <input type="text" name="unitPrice" value="$1000000.00"
readonly="readonly"> will guarantee that the unit price is $1000000.00
when the form is submitted.
--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ -
http://jibbering.com/faq