I am new to Infopath and Sharepoint, and have been reading everything I could find online about this, but nothing to solve my problem. We need a form with custom validation (logic in javascript) to take in all the form data and fill in an invisible field in the form. I think the problem with this is that the infopath pages are created dynamically, so it is impossible to just use 'document.getElementById'. The form we are creating is basically a test, and the logic that we need the validator to do acts as a grading script. Does anyone know how to accomplish this? We need to use infopath so that we can view the overall results on sharepoint. Any help would be greatly appreciated. Thanks!

1 Answer 1


Only reasonable solution for using javascript on InfoPath form would be to create custom page, host InfoPath in webpart and add javascript directly to page. Main issue here is that InfoPath controls ID's are dinamically generated so it is challenge to 'find them' with javascript. A while back I developed one simple solution by using jQuery (and again it was very simple).

But you really should consider different approach: All logic that you need (and probably much more) can be found in functions available in InfoPath. With some logic, rules, hidden fields and calculations you can make wonders.

Some basic info can be found here:


Alternatively, if InfoPath functionalities doesn't meet your requirements, you can do your logic by writing some code behind.

In my opinion Javascript is last option (or even not an option).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.