Let $G$ be a graph, and let $g$ and $f$ be two integer-valued functions defined on $V(G)$ satisfying $a\leq g(x)\leq f(x)-r\leq b-r$ for any $x\in V(G)$, where $a,b$ and $r$ be three nonnegative integers with $1\leq a\leq b-r$. In this paper, we verify that $G$ contains a fractional $(g,f)$-factor if its connectivity $\kappa(G)$ and independence number $\alpha(G)$ satisfy $\kappa(G)\geq\max\Big\{\frac{(b+1)(b-r+1)}2,\frac{(b-r+1)^2\alpha(G)}{4(a+r)}\Big\}$. The result is best possible in some sense.