Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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;
    }
like image 397
BigJobbies Avatar asked Jul 09 '26 01:07

BigJobbies


1 Answers

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

right? :)

like image 77
tekknolagi Avatar answered Jul 10 '26 14:07

tekknolagi