President Valery Giscard d'Estaing has received a serious warning from the French electorate to rethink his policies and electoral strategy if he is going to win reelection next spring.

Giscardist candidates were eliminated in seven parliamentary by-elections across the country Sunday, and the Socialist Party of Francois Mitterrand, Giscard's main presidential challenger, was the chief beneficiary.

At more than five months from the presidential election, this does not necessarily mean that Giscard's reelection is in danger. French voters are good at using opportunities like the by-elections to express discontent and then drawing back from the brink of the unknown.

But the results showed that Mitterrand's party no longer seems to many moderate voters like the dangerous gamble it once did when it was formally allied to the Communist Party.

The Giscardist party, which held three of the seven seats at stake, emerged without a single one. The Socialists, who had held two of the districts, emerged with four. A fifth went to their close allies, the Radicals of the Left, and the other two went to Gaullists.

The behavior of voters in France's peculiar two-round election system demonstrated that it is possible for Mitterrand to put together a winning coalition of those discontented with Giscard's seven-year-rule: Communists, Socialists, miscellaneous leftists, ecologists and, above all, Gaullists.

The Gaullists, still the largest element in Giscard's parliamentary majority, have become increasingly disenchanted with his domestic economic policies and with alleged softness toward the Soviet Union.

In the runoff elections Sunday between the top two candidates from the first-round voting the previous Sunday, wherever Gaullist voters were given a choice between a Socialist or Giscardist, a quarter to a third of the Gaullists favored a Socialist over a candidate of the president's party.

Despite a drumbeat of accusations by the Communist Party leadership that the Socialist Party has turned to the right, party followers seem to have voted almost to a man for the Socialists. The Communist leaders gave lukewarm endorsements to the four winning Socialists, but party headquarters called for abstention in the case of the Radicals.

The local party organization in the south central Aveyron district, reflecting deep splits inside the party, refused to follow directives from Paris and went all-out for the winning noncommunist leftist. Instead of hailing the showing of the left, the Communist Party newspaper l'Humanite today complained that the Gaullist votes for socialists "confirm . . . the intrigues and deals being made between the right and the Socialist Party."

The results seemed to indicate, however, that the Communist electorate has not accepted its party's assertions that the Socialists are the ones who were responsible for breaking up the leftist alliance in 1978, preventing a victory of the left in the last general elections in March of that year.

Socialists voters Sunday showed willingness to reciprocate Gaullist favors. In a district near the Swiss border, where former Prime Minister Edgar Faure, now a Giscardist, resigned after moving from the National Assembly to the Senate, the Giscardist emerged from the first round with a comfortable 35 percent of the vote against the runnerup, a Gaullist with 28 percent of the vote. But Socialist voters turned the tide, and the Gaullist got a total of 51.5 percent in the runoff.

A Giscardist party spokesman said he was "saddened" to see the Gaullists hailing the national results as a victory. Despite opinion polls showing the Giscard is still substantially ahead of Mitterrand in voting intentions for the presidential runoff in May, Sunday's results show othat a winning formula is possible for the Socialist leader who has been widely dismissed as a has-been.This will be his third presidential try, and he came within 300,000 votes of Giscard in mainland France seven years ago.

The results showed that, even if it is not expressed in the ultimate outcome next May, seven years in power has created broad dissatisfaction with Giscard among voters who may not look forward to a total of 14 years of the same president. That would be a record for any French republic.

The results also showed a nostalgia among the Communist voters for a leftist unity that Communist leader Georges Marchais has failed to reduce by depicting Giscard and Mitterrand as Tweedledum and Tweedledee, with the objective of getting Giscard reelected rather than Marchais' rival for leadership of the left.