B
B
Bahtiar Akimkanov2020-03-22 11:09:45
PHP
Bahtiar Akimkanov, 2020-03-22 11:09:45

What methods to use with jquery to get data from the form that there are more than 5 characters?

What methods to use with jquery to get data from the form that there are more than 5 characters and if there are more than 5 characters, then make the submit button active or hang an additional class on it

<form class="form">
 <input type="text" name="username" />
 <input type="text" name="password" />
 <input type="submit" value="Войти" disabled />
</form>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Kirill Nesmeyanov, 2019-08-25
@SerafimArts

Maybe there are better options?

Make a lexer, implement a parser, build an AST and play with it. Quite a better option.

0
0xD34F, 2020-03-22
@Bahtiar

$('form').on('input', function() {
  const disabled = $('[type="text"]', this).get().some(n => n.value.length < 5);
  $('[type="submit"]', this).prop('disabled', disabled);
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question