Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function name(){
- var pole1 = $('#pole1');
- var pole2 = $('#pole2');
- var txt1 = pole1.val();
- var txt2 = pole2.val();
- if (txt1 != "") {
- pole2.val( txt2 + txt1 +"\n");//первое txt2 нужно иначе он удалит и поставит txt1
- pole1.val("").focus();
- }else {
- alert( 'поле не заполнено');
- pole1.focus();
- }
- }
- $('form').submit(function(){
- var val = $("#pole1").val();
- alert("текущее значение\n" + val);
- $("#pole1").focus();
- return false;
- });
- $("#pole1").keypress(function(e){
- if (e.keyCode==13) {//13 это enter
- name();
- return false;
- }
- });
- $('#btn1').click(function(){
- name();
- });
- /*html*/
- <form action="test.php" method="GET">
- <input type="text" id="pole1"><br>
- <input type="button" id="btn1" value="add-name"><br>
- <textarea name="pole2" id="pole2" cols="15" rows="10"></textarea><br>
- <input type="submit" value=" значение поля"><br>
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement