Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change validation not working with NS7 large textbox info

Status
Not open for further replies.

toyt78

Technical User
Apr 5, 2005
125
US
I have a JS that checks if my selects, text and textboxes were changed on a form and lets the form process if any changes were made. If no changes were made then it pops up an alert message. It works in IE and but wont work in NS7 when a textbox has alot of info in it.

Please advise of a better way to do this or how I can get it to work in NS7:
Code:
<script>
function checkF_status(myFrm) {
var el, opt, i = 0, j;
while (el = myFrm.elements[i++]) {
switch (el.type) {
case 'text' :
case 'textarea' :
if (el.value != el.defaultValue) return F_isChanged(myFrm);
break;
case 'radio' :
case 'checkbox' :
if ((el.checked && !el.defaultChecked) || (!el.checked && el.defaultChecked)) return F_isChanged(myFrm);
break;
case 'select-one' :
case 'select-multiple' :
j = 0;
while (opt = el.options[j++]) if ((opt.selected && !opt.defaultSelected) || (!opt.selected && opt.defaultSelected))
return F_isChanged(myFrm);
break;
}
}
alert("NO CHANGES MADE SO NOT PROCESSING");
return false;
}

function F_isChanged(myFrm) {
return true;
}
</script>

<form name="myFrm" action="actionpage.cfm" method="post" onsubmit="return checkF_status(this);">
<textarea rows="3" cols="40" name="ye" wrap="hard">IN NS 7, IF I HAVE ALOT OF INFO HERE IT WONT WORK, BUT WORKS IN IE ALL THE TIME</textarea><br /><br />
<input type="text" value="blah"><br /><br />
<input type="radio" name="r1" checked="checked"> foo<br />
<input type="radio" name="r1"> bar<br />
<input type="checkbox" name="c1" checked="checked"> hoo
<input type="checkbox" name="c1"> hah<br /><br />
<input type="checkbox" name="c2">eek<br /><br />
<SELECT NAME="fieldname">  
<OPTION VALUE="a" SELECTED>a</OPTION> 
<OPTION VALUE="b">b</OPTION> 
<OPTION VALUE="c">c</OPTION> 
</SELECT> 
<input type="submit">
</form>
 
Your problem lies with NN7 and its handling of default values. I remember a bug a few years back witha similar issue... and it came down to (from memory) NN7 being buggy with the way it handles defaultValues.

While I can't seem to get to it from work (our proxy blocks the strangest things), this article might possibly help:


Dan


[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Thanks,

Can you recommend another way I can check the textbox in NN7?
 
I fetched the length of both the defaultValue and value I notice there is a difference of 1 for each time it starts a new line in the textarea box.

Code:
alert(el.value.length +'\n'+el.defaultValue.length);

The defaultValue seems to be adding an extra number for each new line.
How would I handle this? I assume I should do a replace or reg expression to get rid of something but not sure what is being added and how I would do this??
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top