There has been some discussion about this here already but I haven’t found anything to help me. This note - http://www-10.lotus.com/ldd/nd6forum.nsf/55c38d716d632d9b8525689b005ba1c0/6db36a72e583bf1385256c61006cbff0?OpenDocument - says the problem has been spr’d but I searched that database and couldn’t find an SPR that seemed to be for this problem, but of course maybe I searched for the wrong string.
We want to upgrade to Notes/Domino 6 by the end of July but some of our major applications are web-based. When a field isn’t filled out properly and input validation occurs, the user is told to use the back button to return to the form but they return to a blank form. I changed this by adding javascript on the field itself and on the onsubmit event for the form. That worked fine for the initial submission of the document, but when editors came in to make changes, upon saving the form they either got an error message - " ‘window.document.forms.0.fieldname.value’ is not an object ", or the document was just not saved, no indication given other than it didn’t do what the $$Return said it should. I’m certainly no expert at javascript so maybe just a change to that would resolve the problem, I just don’t know where to change it. Here’s what it looks like:
on the field onblur event -
checkamt(window.document.forms[0].Amount)
on the form onsubmit event -
checkamt(window.document.forms[0].Amount)
on the form JSHeader -
function checkamt(ramount) {
var amtVal = ramount.value;
if(amtVal == “”) {
alert(“An amount over $500 must be entered.”)
ramount.focus();
return false;
}
}
Any help or information on this would really be appreciated.
thanks, Mary
Subject: Browser back button- fields are cleared; input validation vs javascript
Here are a couple examples of how I use JavaScript to validate on the web:
The examples have the following in the ‘onSubmit’ event of the form:
return validate();
Then, any of the following goes into the ‘JS Header’ of the form:
- To verify a field is not blank:
function validate(){
var doc = document.forms[0];
if(doc.FieldName.value == ‘’){
doc.FieldName.focus();
alert(Error Message.');
return false;
}
return true;
}
- Since you are validating digits in your example, this can be adjusted to look for a cartain length in digits:
function Validation() {
re3 = /^\d\d\d$/; (Keep adding “\d” for more digits
AreaCode = document.forms[0].Fax;
if (!(re3.test(AreaCode.value))) {
alert(‘Verify 3 Digit Area Code’);
AreaCode.focus();
return false;
}
return true;
}
- To just check for length, use:
function validate(){
var doc = document.forms[0];
if(doc.FieldName.value.length != 7 ){
doc.FieldName.focus();
alert(‘Error Message.’);
return false;
}
Hope this helps.
-J
Subject: RE: Browser back button- fields are cleared; input validation vs javascript
Jeremy, thanks for your feedback and examples. I tried them, but it didn’t change anything. Again, the javascript works fine for a person creating a document, but this is a workflow application and a document goes through an approval type process. When the ‘approver’ goes to edit the document, that’s when it doesn’t work, and gives the error and/or refuses to save the document. Certainly open to other ideas…
thanks, Mary
Subject: RE: Browser back button- fields are cleared; input validation vs javascript
Is the Amount field actually available to the approver? As a field, I mean, not simply as visible text.
While I hate to use this option myself, “Generate HTML for all fields” will get around the issue by placing a type=“hidden” HTML version of the field on the web document.
You can also get around it in JavaScript:
if (document.forms[0].Amount.value) {
}
In this case, the if will be fed a value of false if the field does not exist as a field on the web document. Since it will most certainly exist on the freshly opened form, you still get validation of the original submitter’s value.
Subject: RE: Browser back button- fields are cleared; input validation vs javascript
The field isn’t actually available to the approver. The approver sees a computed by field that gets that field. That’s probably the problem huh?
I modified the jsheader and here’s what I have now, based on your suggestion above:
function validate(){
if (document.forms.ReqAmount.value) {
var doc = document.forms[0];
if(doc.ReqAmount.value == ‘’){
doc.ReqAmount.focus();
alert(‘An amount over $500 must be entered.’);
}return false;
}
return true;
}
I’m not exactly sure if I have the syntax correct tho, but in any case, that didn’t change anything.
thanks, Mary
Subject: RE: Browser back button- fields are cleared; input validation vs javascript
Yep. Computed fields are not rendered to the web page by default. By putting the if (document.forms[0].FieldName.value) {} wrapper around the actual value check, the validation for the field will be skipped when the approver submits the form:
function checkamt(ramount) {
if (ramount.value) {
var amtVal = ramount.value;
if(amtVal == “”) {
alert(“An amount over $500 must be entered.”)
ramount.focus();
return false;
}
}
}
Subject: RE: Browser back button- fields are cleared; input validation vs javascript
Stan, I’m trying this now, sorry about the previous post/response, after I posted it I checked it out more carefully (duh!) and saw that the answer was there. I edited the response but you were too fast for me. Anyway, I will edit the script again, using your example and report back.
thank you so much!
Mary
Subject: RE: Browser back button- fields are cleared; input validation vs javascript
Stan, hoping you are still out there…
It still isn’t working, it’s doing the exact same thing.
Any other ideas?
thanks so much.
Mary
Subject: Resolved! Browser back button- fields are cleared; input validation vs javascript
OK, I’m not exactly sure what is the real difference in the logic between this and what Stan and Jeremy submitted, but this works for me. Hope it helps others too.
function validate(){
var retValue = false; //Set this up as a boolean that is the returned value for the method
var doc = document.forms[0]; //Declare a pointer to the document.forms object for efficiency.
var reqAmountField = null; //We'll set this pointer later to the ReqAmountField if we have it
if(doc.ReqAmount != null){
reqAmountField = doc.ReqAmount; //We know that we've got the ReqAmountField, so assign it to our pointer
retValue = parseInt(reqAmountField.value) > 500; //Assign the result of the comparison to retValue
if(retValue == false){
alert('An amount over $500 must be entered');
reqAmountField.focus();
}
}
else
retValue = true; //Assuming this is what you want if the field isn't there;)
return(retValue);
}
Subject: Has “Browser back button- fields are cleared; input validation” been fixed?
Has Lotus addressed the problem whereby the form is cleared if an input validation formula kicks in on submit? I only recently seemed to run across this although we upgraded to Domino 6.5 late last year – I thought I might have introduced it when I added session authentication functionality. I have been changing my validation formulas to Javascript but it’s a royal pain for very simple validation (did you pick at least one meeting to attend, for example) if you are like me (not a js wizard).
Can anyone tell me if an upgrade to a 6.5x will help?