V
V
Valeriy19972015-08-25 21:59:27
JavaScript
Valeriy1997, 2015-08-25 21:59:27

Why does the code conflict?

I make a mask for a text field, and I do a check with water in this field: but for some reason only one code works

$(document).ready(function() {

//mask_form

// работает либо эта строка
  $("#phone").mask(" +38-(099)-999-99-99");
 // либо эта
  $(".telephone").on('input', function () {

  alert("Привит")

  });
});


here is the code for the library I use for the mask: jsfiddle.net/t52ka/25

maybe the problem is because of a conflict with it? But there are no errors (

Tell me how to solve this problem?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Zelensky, 2015-08-26
@SergeyZelensky-Rostov

function on
you are not using the on() function correctly, read the attached link, if you don’t understand, write, I will explain

V
Valeriy1997, 2015-08-26
@Valeriy1997

I think that the problem can be solved by making this code run first:

$(".telephone").on('input', function () {

  alert("Привит")

  });

then this
But do not know how to do it ?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question