From Elder Law Answers: (click for full article)
Millions of people are affected by dementia, and unfortunately many of them do not have all their estate planning affairs in order before the symptoms start. If you or a loved one has dementia, it may not be too late to sign a will or other documents, but certain criteria must be met to ensure that the signer is mentally competent.
In order for a will to be valid, the person signing must have "testamentary capacity," which means he or she must understand the implications of what is being signed. Simply because you have a form of mental illness or disease does not mean that you automatically lack the required mental capacity. As long as you have periods of lucidity, you may still be competent to sign a will.