uitextfieldvalidation in iphone
<p>i have a uitextfield and i am validating text field and the validation is adding "-"(hypen)for every 3 numbers. and it is working fine </p>

<p>and the code is as follows 
but now i want to change the validation in such a way that to restrict no of characters to 10 and adding "-" after 3rd and 7th place dynamically while entering and editing 
[ex:123-456-7890] it should be done while editing also...</p>

<pre><code>- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {

NSString *separator = @"-";
int seperatorInterval = 3;
NSString *originalString = [textField.text stringByReplacingOccurrencesOfString:separator withString:@""];

if (![originalString isEqualToString:@""] &amp;&amp; ![string isEqualToString:@""]) {

    NSString *lastChar = [textField.text substringFromIndex:[textField.text length] - 1];
    int modulus = [originalString length] % seperatorInterval;

    if (![lastChar isEqualToString:separator] &amp;&amp; modulus == 0) {

        textField.text = [textField.text stringByAppendingString:separator];
    }
}

return YES;
</code></pre>

<p>}
 but now i want to change the validation in such a way that to restrict no of characters to 10 and adding "-" after 3rd and 7th place dynamically while entering and editing<br>
   [ex:123-456-7890]
it should be done while editing also... </p>
