There are actually a few factors involved in whether the Church recognizes a marriage as valid or not. Now, I know I have links to support what I am about to say but I can not locate them right now. I was able to find some info in the Code of Canon Law but it takes a bit to research. :/ So, this is going off of memory… Please forgive me if I have mis-stated anything, but this should give you a better idea as this is pretty general.
As Valerie stated above with the quote from the Catechism, in paragraph 1660 is says “marriage between the baptized” meaning for a non-baptized individual certain things may not apply. She is correct in stating that a JoP is NOT a sacrament.
For marriages between 2 practicing Catholics, it must be performed by a priest. A JoP (Justice of Peace) is considered invalid.
For 2 non-Catholics, it is recognizable but if they become Catholic they should have the Church bless it.
For non-practicing Catholics, if they have turned away from the Church and refuse its teachings, a JoP marriage can be valid. There are certain things pertaining to this to meet the requirements for “non-practicing.”
If one party is Catholic and practicing, a JoP marriage is considered invalid and illicit.
For Catholics marrying non-Catholics, it is possible to have a non-Catholic wedding but a dispensation must be obtained prior and permission from you parish priest. A JoP alone, even with a dispensation, is invalid; there must be a religious component to the ceremony (not 100% on this last part though).
I hope this helps. I am really sorry that I couldn’t remember the links to quote but I know it is possible to find them. It will just take a bit of web searching on your part.