An else if statement for unwanted characters and too short a length of characters for edittext
<p>I have an <code>edittext</code> variable named <code>getusername</code> I wish to use in an if statement.</p>

<p>I wish to check for unwanted characters like !,@,#,$,%,^,&amp;,*,(,),etc. I also want to make sure the text from edittext will not be less than 3 characters.</p>

<p>Right now i'm using <code>getusername.getText().toString()</code> to get the values in edittext but I want to use an if statement that toasts "success" if the characters in the edittext match my exceptions. and if not toasts what the problem is.</p>

<p>Is there anyway to do this?</p>

<p>My current code asterisks mark where i need help on with my comments.</p>

<pre><code>if (getusername.getText().toString() *does not have any spaces or invalid characters*)
and (getusername.getText().toString() *has more than 3 characters*) {

Toast.makeText(this, "Success.",Toast.LENGTH_SHORT).show();

} else if (getusername.getText().toString() *has spaces or invalid characters*) {

Toast.makeText(this, "Invalid Characters",Toast.LENGTH_SHORT).show();

} else if (getusername.getText().toString() *does not have more than 3 characters*) {

Toast.makeText(this, "Not enough characters",Toast.LENGTH_SHORT).show();

} else {

Toast.makeText(this, "Unknown Error",Toast.LENGTH_SHORT).show();

}
</code></pre>

<p>This shows a general idea of what i'm trying to accomplish. </p>

<p>Thank you in advance.</p>
