I think yours would return a valid password, but [edit]
it won't tell them what's wrong if they enter a short password twice in a row it's not as concise as it could be.
Code:
bool passLength(string) // just print error, and return true/false. Don't read a new pw
bool containDigit(string) // just print error, and return true/false. Don't read a new pw
string getPW()
{
string pw = read line;
while (( ! passlength(pw) ) || ( ! containDigit(pw) ))
{
pw = read line;
}
return pw;
}