Bootstrap 4 在单击按钮时更改占位符文本(&A);单击提交时更改占位符文本的引导验证

Bootstrap 4 在单击按钮时更改占位符文本(&A);单击提交时更改占位符文本的引导验证,bootstrap-4,Bootstrap 4,我对web开发非常陌生,需要一些验证方面的帮助。 我目前正在为一个正在使用Bootstrap构建的网站设计一个表单。 从代码中可以看到,有3个按钮编号为1、2和3,3个输入,一个名称输入,最后还有一个提交按钮。 当前,当您按1、2或3时,它只会更改“第一选择”输入框中的占位符文本。 我需要帮助的是: 按钮可用于3个占位符中的任何一个 1. If "First Choice" is already selected (placeholder text has chang

我对web开发非常陌生,需要一些验证方面的帮助。 我目前正在为一个正在使用Bootstrap构建的网站设计一个表单。 从代码中可以看到,有3个按钮编号为1、2和3,3个输入,一个名称输入,最后还有一个提交按钮。 当前,当您按1、2或3时,它只会更改“第一选择”输入框中的占位符文本。 我需要帮助的是: 按钮可用于3个占位符中的任何一个

    1. If "First Choice" is already selected (placeholder text has changed) then select "Second Choice", if "Second Choice" is selected (placeholder text has changed) then select "Third Choice".
    
    or (not sure which one of these I'll use yet)
    
    2. Any button can be used again if already selected to change any of the 3 placeholder text inputs.
    
    3. How do I validate if all 3 inputs have been changed on clicking submit?
    
    4. How do I validate the name input has been filled in?
    
    5. How do I validate if all 4 inputs have been changed on submitting?
    
    6. Am I doing this correctly? Or is there a simpler way?
    
如果这是一大堆问题,只是想让我的头绕过去,我道歉

    Hope you can help
    
    Daz

钮扣{
保证金:50px 0 50px 0;
}
.集装箱{
边框:纯黑1px;
宽度:60%;
}
#f2、f3、f4、f6{
文本对齐:居中;
}
#f5{
背景色:黑色;
颜色:白色;
文本对齐:居中;
}
1.
2.
3.




提交
函数changep占位符1(){ selectedTextarea=$('#f2')[0]; selectedTextarea.placeholder=“1”; } 函数changep占位符2(){ selectedTextarea=$('#f2')[0]; selectedTextarea.placeholder=“2”; } 函数changep占位符3(){ selectedTextarea=$('#f2')[0]; selectedTextarea.placeholder=“3”; } ```
欢迎来到Stackoverflow,花几分钟的时间来参观并阅读“我该如何提出一个好问题?”。如果你愿意,你会有更好的机会得到你想要的答案。你的问题有更多的细节、信息、代码等等。记住我们不在你身边。有关无相关代码的问题,请访问Wordpress Stackexchange@。如果您有超过1个问题,则应拆分帖子。您的问题不清楚,也很混乱。您的问题与引导无关,但与javascript和jqueryn有关,您应该添加这些标记以最大限度地利用您的chancesHi AmarineDialog,非常感谢您的建议和指导,我会将其分解并重新发布。干杯
<html lang="en">
<head>
    <title></title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</head>
<style>

button {
    margin:50px 0 50px 0;
}
.container {
    border:solid black 1px;
    width:60%;
}
#f2, #f3, #f4, #f6 {
    text-align:center;
}

#f5 {
    background-color:black;
    color:white;
    text-align:center;
}

</style>
<body>
<div class="container">
    <button type="submit" class="btn btn-lg btn-primary" onclick="changePlaceholder1()">1</button>
    <button type="submit" class="btn btn-lg btn-secondary" onclick="changePlaceholder2()"> 2</button>
    <button type="submit" class="btn btn-lg btn-info" onclick="changePlaceholder3()">3</button>
    <br>    
    <input id="f2" readonly placeholder="First Choice">
    <input id="f3" readonly placeholder="Second Choice">
    <input id="f4" readonly placeholder="Third Choice"><br>
    <br>
    <input id="f6" type="name" placeholder="Name">
    <br>
    <button type="submit" class="btn btn-success">Submit</button>
    <br>
</div>
<script type="text/javascript"> 
    function changePlaceholder1() { 
        selectedTextarea = $('#f2')[0]; 

        selectedTextarea.placeholder = "1";
    }
</script>
<script>
    function changePlaceholder2() { 
        selectedTextarea = $('#f2')[0]; 

        selectedTextarea.placeholder = "2"; 
}
</script>
<script>
    function changePlaceholder3() { 
        selectedTextarea = $('#f2')[0]; 

        selectedTextarea.placeholder = "3";
}
</script>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>
</html>```