I inherited an app from someone else, built in HTML, CSS and JS inside a content editor web part on a page in SharePoint. Thus far I've been able to extend it and resolve outstanding bugs, but one thing that I have been beating my head against is how the JavaScript validation can be extended to other list forms, as everything I've tried isn't working. It not only conducts validation for a date range (if end date is 3 weeks greater than start date) but also sets the value of a lookup column drop down in the newform.aspx file.
I see the javascript in the js file for the validation, however, it doesn't work on my forms even if I point the js to the .aspx form I created. BUT...If I copy the newform.aspx file from the list that it DOES WORK in to another list where it is needed, with the js file for a new page pointing at that new list and form, the validation triggers, as does setting the value of the drop down menu in the form based on the selection in the javascript based content editor web part app. Only problem is then it's pointing to the lookup values from the original list and not the new one. For example:
Original List is HR. Content editor web part points to a newform.aspx file which has date fields that it conducts validation for, and also sets the value of the lookup column field to the value of whatever you clicked on in the CE web part. If the values are HR 1, HR 2, HR3, and you clicked HR 2, it sets the value of the newform.aspx form field to HR 2.
Now, if I create the app for another department in the exact same way, and point the js file to my own newform.aspx file created in what appears to be the same way as the original, the validation and the setting of the drop down menu do not work. The drop down menu does of course show the correct lookup column values, but the autset feature doesn't work.
But if I now swap the newform.aspx file from the list that it does work in to the new list via SharePoint Designer, the valudation and lookup automation works, but with the values of the original list. For this list they should be OPS 1, OPS 2, OPS 3, but they still look to HR 1, HR 2, HR 3.
There is no custom js in a content editor web part in the page of the newform.aspx file that is doing this. From what I can tell, it's all in the js file for the app that is conducting this function of validation, etc. Still no difference. I'm banging my head against this without any resolution. I even tried creating a new content type the same way the original one was created and I still get the same result. The values of the loopup column from the original list, not my new list if I copy the newform.aspx form over, or if I create a new one, I get the right values but none of the js automation or validation.