如何验证微调器提交的值 [英] How to validate an value submitted by a spinner

查看:87
本文介绍了如何验证微调器提交的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在完成一个Web应用程序,并且想对我的微调器进行验证,它应该只允许用户提交一个介于1到50之间的值,但是我想要的是如果用户删除了该值并输入了0,它会在网页上显示一条错误消息,通知用户这是不正确的,微调器的支持已全部验证,因此,如果输入值0,则不会发生任何事情,但是我只是在寻找一个弹出窗口等方式通知用户的方法

i am finishing off a web app, and want to put validation on my spinner, it should only let the user submit a value of between 1 and 50, however what i want is if a user deleted the value and for example entered 0, it to come up with a error message on the webpage informing the user that this is incorrect, the backing to the spinner has all validation, so if a value of 0 was entered, nothing would happen, but i am just looking for a way to inform the user about this, using a pop up etc

这是我给微调器的代码

<h:body>
 <h:form id="myForm"> 
  <p>
   Number of copies (Max of 50) :
   <p:spinner id ="Copies" min="1" max="50" value="#{printerSettings.p}" size ="1"> 
   <!-- allows the user a choice of up to 50, this is more than enough for any situation, if needed this can be removed or raised -->
   <p:ajax update="p"/>
  </p:spinner>
  <div class="whiteSpace"/>   
  <h:outputText value="Copies that will be printed: &nbsp; #{printerSettings.p}" id="p"/>
 </p>

正如我在其他问题中所看到的,我试图添加javascript验证未成功

i have tried to add javascript validation to no success, as you can see in my other question

我的问题是实现目标的最佳方法是什么,有谁能效法我的例子吗?

my question here is what is the best method of achieving my aim, and does any one have any examples i could follow ?

谢谢大家:)

推荐答案

尝试添加此内容:

<f:validateLongRange minimum="1" maximum="50" />

这篇关于如何验证微调器提交的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆