Unruly fans booted from NFL stadiums this year will be required to pass a code-of-conduct exam — or they won’t be allowed back in for another game.

The idea was hatched by a licensed psychotherapist, says the New York Post.

“We’re not trying to squash anyone’s passion. We’re just trying to say don’t be violent,” said Dr. Ari Novick in the report.  

Requirements will vary depending on the stadium, but most of the time the stadium louts will have to pass the test before being allowed back in, he said.

The classes are an effort to stem the rising tide of ugly stadium behavior that has included everything from bare-knuckle brawls to lewd Jets fans who screamed obscenities at women until they exposed their breasts in a rude Gate D tradition at the old Giants Stadium, says the report.  

At the new MetLife Stadium, security chief Daniel DeLorenzi says about 25 fans are ejected from every Jet and Giant game — about 500 rowdies a year.

In 2010, the stadium was the first, along with the New England Patriots’ Gillette Stadium, to employ Novick’s classes.

Fans who get the boot must write DeLorenzi a letter of apology and take the four-hour, $75 online course, available at fanconductclass.com. To pass, they have to get at least 70 percent of the questions correct.

Novick takes in $55 for each test he certifies. Mothers Against Drunk Driving and the HERO Campaign for Designated Drivers split the remainder of the money, the report says.

About 25 percent of those bounced don’t bother to take the course, DeLorenzi noted. Incorrigible wrongoers wind up on the “unforgiven” list — a book containing the name, photo and seat number of every booted fan. Security guards monitors the stands each game for the unforgiven, says the report, and if they are caught, they’re arrested for trespassing.