In James 2:19, we see that the demons believe "mental assent" that "there is one God," but they do not believe in/have faith in/trust in/reliance in Jesus Christ for salvation. In other words, they do not believe on the Lord Jesus Christ (Acts 16:31) and are not saved. Their trust and reliance is in Satan, as demonstrated by their rebellion in heaven and continuous evil works.
The pharisees did not believe in/have faith in/trust in/reliance in Jesus Christ for salvation either. In regards to Matthew 5:20 - "unless your righteousness surpasses that of the pharisees and the teachers of the law, you will certainly not enter the kingdom of heaven." This statement from Jesus would come as a shock to the multitude of people who had great admiration of the pharisees and the teachers of the law, for their knowledge of the law and seeming righteousness and holiness in external observance of the law, yet Jesus points out their righteousness was defective. *The righteousness that exceeds the "righteousness of the scribes and the pharisees" (self righteousness) is the righteousness of God which is from God by faith.
Philippians 3:9 - and be found in Him, not having my own righteousness, which is from the law, but that which is through faith in Christ, therighteousness which is from God by faith.
Romans 3:21 - But now the righteousness of God apart from the law is revealed, being witnessed by the Law and the Prophets, 22
even the righteousness of God, through faith in Jesus Christ, to all and on all who believe. For there is no difference.
Romans 4:5 - But to him who does not work but believes on Him who justifies the ungodly, his faith is accounted for righteousness, 6 just as David also describes the blessedness of the man to whom God imputes righteousness apart from works.
In Romans 10:3-4, we read - "For they (Israel) being ignorant of God's righteousness, and seeking to establish their own righteousness, have not submitted to the righteousness of God. For Christ is the end of the law for righteousness to everyone who BELIEVES.