小编Jac*_*cel的帖子

春天百里香文本下一行

我想将来自我的控制器的消息传递回我的百里香叶模板并在多行上设置值。

在我的控制器中,我设置了这样的文本。

String message="item A \n item B \n Item C \n Item D"; //it could be 4 values, could 10 values.

modelAndView.addObject("successMessage", message);
Run Code Online (Sandbox Code Playgroud)

在我的 thymeleaf 模板中,我将其设置为这样。

<p th:utext="${successMessage}"></p>
Run Code Online (Sandbox Code Playgroud)

我希望它显示为

item A
item B
item C
item D
Run Code Online (Sandbox Code Playgroud)

在前端,并非全部在一行中。我该怎么做?多谢。

html spring thymeleaf

5
推荐指数
1
解决办法
5416
查看次数

React Material - ui 文本字段验证:设置自定义错误消息

我有一个材质 UI 文本字段,在输入某个值后,我想在自定义验证失败时设置一条错误消息。

仅当输入空白值时,我才能在错误消息中进行设置。因此,我想添加我自己的客户错误消息,而不是空白值错误消息。

const checkValue = (newValue) => {
    var other = { 'a': 1 };
    if(!_.isEqual(newValue, other)) {
        alert('value is correct.');
        //I want to set error message next to field value is not correct.
    }
}

<TextField
    id="form-value"
    className={classes.textField}
    margin="dense"
    label={'value'}
    value={value}
    onKeyUp={e => { checkValue(e.target.value); }}
    onChange={e => { checkValue(e.target.value); }}
    variant="outlined"
    error={value=== ""}
    helperText={value=== "" ? 'Please enter a value!' : ' '}
    fullWidth
>
Run Code Online (Sandbox Code Playgroud)

reactjs material-ui

5
推荐指数
1
解决办法
2万
查看次数

html jquery禁用值按钮

<html>
   <head>
       <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
   </head>
   <body>
      <script>
         function checkValue() {         
         var id=$('#testValue').val();
         if(id < 10){
                $('#bb').text("value is LESS than 10. Disable Submit button please!");
                $('#submitBtn').disabled = true;
            }else{
                $('#bb').text("value is MORE than 10. Enable submit button please!");
                $('#submitBtn').disabled = false;
            }
         }
        function testSubmit(){
            alert('test submit clicked.');
        }
      </script>
      input value:
      <input type="text"  id="testValue" maxlength="6" size="10" required>
      <button type="button" name="action" onclick="checkValue()"    value="issueInvoice">TEST VALUE</button>
      <p style="text-align:left" class="txt-centered label-registersuccess font-red" id="bb"></p>
      <button type="button" name="action" id="submitBtn"  onclick="testSubmit()"    value="issueInvoice">submit button</button> 
   </body>
</html>
Run Code Online (Sandbox Code Playgroud)

我有这个简单的表格。我输入了一个值。如果小于TEN,则显示文本,“值小于10”。我也想在这种情况下禁用该按钮。我该怎么做?然后,当值大于TEN时,显示“值大于10”并启用按钮。

我该怎么做呢? …

html javascript jquery

0
推荐指数
1
解决办法
6071
查看次数

标签 统计

html ×2

javascript ×1

jquery ×1

material-ui ×1

reactjs ×1

spring ×1

thymeleaf ×1