Well according to Lucas, their is no rule against Jedi having sex. There isn’t an outright ban on marriage either since it’s not an actual part of the Code but it is a tradition that Jedi seem to have adapted after the war with Exar Kun and Ulic Qel-Droma. There is at least one member of the Council during the prequels who was married because his people required all citizens to be married in order to increase the population. I do think if the Council had discovered that Anakin was married they would have exiled him in a heartbeat. Although according to the EU he wasn’t the only Jedi of his era secretly married, in Jedi Trial Anakin runs into Corran Horn’s father who is also secretly married. There were other Jedi who had secret relationships during the prequel area and one of the more popular theories among EU fans is that Obi-Wan is Mara Jade’s father (which is not a theory that I believe) from one of these secret relationships.
The no marriage thing is the one tradition that I’m extremely glad Luke didn’t implement with his New Jedi Order.