You can do this with formatting rules, more information available here http://office.microsoft.com/en-nz/infopath-help/add-formatting-rules-HA101783371.aspx
Specifically the Data Entry Patterns section of this article.
Use the 'matches pattern' or 'does not match pattern' on the text-box control to format it (text or background ...