Solve in small pieces -
- Count characters - are there enough?
Put them in a function as a cascade that makes the most efficient sense. Check the value when the person leaves the input box. Return true/false. Handle problems if any.*
* You can be more specific about the error but just saying it's invalid is enough.