  Let $G$ be a graph and let $f$ be a positive integer-valued function on
$V(G)$. Assume that for all $S\subseteq V(G)$, $$\sum_{v\in I(G\setminus
S)}f(v)(f(v)+1)\le |S|,$$ where $I(G\setminus S)$ denotes the set of isolated
vertices of $G\setminus S$. In this paper, we show that if for all $S\subseteq
V(G)$, $$\omega(G\setminus S)\le \sum_{v\in S}(f(v)-1)+1,$$ and $\sum_{v\in
V(G)}f(v)$ is even, then $G$ has a factor $F$ such that for each vertex $v$,
$d_F(v)=f(v)$, where $\omega(G\setminus S)$ denotes the number of components of
$G\setminus S$. Moreover, we show that if for all $S\subseteq V(G)$,
$$\omega(G\setminus S)\le \frac{1}{4}|S|+1,$$ and $f\ge 2$, then $G$ has a
connected factor $H$ such that for each vertex $v$, $d_H(v)\in
\{f(v),f(v)+1\}$.
