需要输入并且 javascript 不工作
required with input and javascript not working
我想在提交前设置一个必填项,但不知道行不通吗?可以超过 JS 吗?感谢您的支持
<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>
您的表单字段必须在 form
元素内。
此外(仅供参考),您不需要为每个函数单独的 script
标签。
<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>
您没有表单标签。添加这样的表单标签:
<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>
我想在提交前设置一个必填项,但不知道行不通吗?可以超过 JS 吗?感谢您的支持
<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>
您的表单字段必须在 form
元素内。
此外(仅供参考),您不需要为每个函数单独的 script
标签。
<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>
您没有表单标签。添加这样的表单标签:
<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>