2

I would like to set a required before submitting but isn't work any idea? May over JS ? Thank you for your support

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<tr><td><input type="text" size"30" placeholder="Text " maxlength="10" id="source" required>
<button type="submit" class="formButton" id="submit">Submit</button></td></tr>

<tr><td height="20px"></td></tr>                            
<tr><td><input type="text" style="border:none" size="40" id="target" class="form69" onClick="myFunct()"></td></tr>
<tr><td height="150px"></td></tr>   

<script>
$(".formButton").click(function() {
 $(".form69").show();
});
</script>

<script>
$('#submit').click(function(){
var source = $('#source').val();
$('#target').val('text test' + source + ' text');
}); 
</script> 

2 Answers 2

2

Your form fields must be inside of a form element.

Also (FYI), you don't need a separate script tag for each of your functions.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<form>
  <input type="text" size="30" placeholder="Text " maxlength="10" id="source" required>
  <button type="submit" class="formButton" id="submit">Submit</button>

  <input type="text" style="border:none" size="40" id="target" class="form69" onClick="myFunct()">
</form>

<script>
  $(".formButton").click(function() {
   $(".form69").show();
  });

  $('#submit').click(function(){
    var source = $('#source').val();
    $('#target').val('text test' + source + ' text');
  }); 
</script>

Sign up to request clarification or add additional context in comments.

Comments

1

You don't have a form tag. Add a form tag like this:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form>
<tr><td><input type="text" size"30" placeholder="Text " maxlength="10" id="source" required>
<button type="submit" class="formButton" id="submit">Submit</button></td></tr>
</form>

<tr><td height="20px"></td></tr>                            
<tr><td><input type="text" style="border:none" size="40" id="target" class="form69" onClick="myFunct()"></td></tr>
<tr><td height="150px"></td></tr>   

<script>
$(".formButton").click(function() {
 $(".form69").show();
});
</script>

<script>
$('#submit').click(function(){
var source = $('#source').val();
$('#target').val('text test' + source + ' text');
}); 
</script> 

1 Comment

this script will display the output whatever i put in the text fill. if i set a form it will submitted to nirvana like reload the page. that's why is it possible without form ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.