BigJobbies
BigJobbies

Reputation: 4343

jQuery - Check if a string is larger than 4 characters

I just have a quick question, im wondering if someone could help me.

I have the following script that someone has written which returns an error if there are no characters in the text field.

I want to modify the script so that it returns an error if there are less than 4 characters, but im not quite sure how.

Current script is as follows:

    if(!isString($.trim(iUsername.val()))){ //If username is not correct
        iUsername.siblings('.error').text('You must enter a username.');
        error = true;
    }

Upvotes: 2

Views: 9389

Answers (1)

tekknolagi
tekknolagi

Reputation: 11022

if ($(textId).val().length < 4) { err; }

right? :)

Upvotes: 9

Related Questions