Check request.form[“field”] string length not working in ASP.net

I am currently trying to validate my ASP.net form. I need to be to ensure that the user has entered a password of at least 5 characters. I have done a check to make sure that something is valid using the following code\[code\]else if (Request.Form["txtPassword"] == ""){}\[/code\]I am then checking that the characters is not less than 5 by using the following code\[code\]if (Request.Form["txtPassword"].Length < 5){}\[/code\]However, when I run the form and submit it, instead of it displaying the error to the user about the password length but I keep on getting an error from visual studio before I have tried to submit the form it displays Object reference not set to an instance of an object. This error is only displayed for when I am checking the length not if I am checking the String is empty.Thanks for any help you can provide.
 
Top