Advertisement
Guest User

Untitled

a guest
Jan 16th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. function name(){
  2. var pole1 = $('#pole1');
  3. var pole2 = $('#pole2');
  4. var txt1 = pole1.val();
  5. var txt2 = pole2.val();
  6. if (txt1 != "") {
  7. pole2.val( txt2 + txt1 +"\n");//первое txt2 нужно иначе он удалит и поставит txt1
  8. pole1.val("").focus();
  9. }else {
  10. alert( 'поле не заполнено');
  11. pole1.focus();
  12. }
  13. }
  14. $('form').submit(function(){
  15. var val = $("#pole1").val();
  16. alert("текущее значение\n" + val);
  17. $("#pole1").focus();
  18. return false;
  19. });
  20. $("#pole1").keypress(function(e){
  21. if (e.keyCode==13) {//13 это enter
  22. name();
  23. return false;
  24. }
  25. });
  26. $('#btn1').click(function(){
  27. name();
  28. });
  29.  
  30.  
  31. /*html*/
  32. <form action="test.php" method="GET">
  33. <input type="text" id="pole1"><br>
  34. <input type="button" id="btn1" value="add-name"><br>
  35. <textarea name="pole2" id="pole2" cols="15" rows="10"></textarea><br>
  36. <input type="submit" value=" значение поля"><br>
  37. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement