There is a phone number entry field, you need to:

  1. Pressing clears the text entry field.
  2. if the input field is empty, then when you click on the button, the message "fill in the field" is displayed

Tracking text input required , added scripts for cleaning, required work ceases to work.

 Напишите телефон <input name="Телефон" type="text" class="pole" required placeholder="+780080080" /> Отправить <input class="tab_zakaz_knopka" name="_submit_" type="image" src="img/zakazat.jpg" onfocus="if(value=='+780080080'){value=''}" onblur="if(value=='') { value='+780080080' }"/> 

If add to input:

 onfocus="if(value=='+780080080') {value=''}" onblur="if(value=='') {value='+780080080'}" 
  • Add script code because it is not clear from the question what the scripts are and what they influence. - Sergey Glazirin
  • @Sergey Glazirin look, added - Liana

1 answer 1

 $(function(){ //когда поле в фокусе $('.pole').focus(function(){ //убераем подсказку формата номера и обнуляем значение value $(this).attr('placeholder', ''); $(this).val(''); //когда инпут теряет фокус $(this).blur(function(){ //если в инпуте пусто то прописываем подсказку формата номера if($(this).val()==''){ $(this).attr('placeholder', '+780080080'); } }); }); }); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <form> Напишите телефон <input name="Телефон" type="text" class="pole" required placeholder="+780080080" /> Отправить <input class="tab_zakaz_knopka" name="_submit_" type="image" src="img/zakazat.jpg" /> </form> 

  • thank you! - Liana