验证2:增加字典条目和修改字典条目

 增加字典条目,注意传递参数id。点击保存,onclick调用验证方法:

<jsfext:javascript path="/cn/hnisi/gdrk/sys/zdgl/zdtm/js/Validation.js" /> <td align="right" style="font-size: 10pt" mce_style="font-size: 10pt"> 字典代码: </td> <td> <jsfext:inputText id="dm" size="35" tabindex="4" value="#{dictionaryModel.dictionaryCode}" required="true" cnName="字典条目代码" maxlength="50"> <jsfext:jseventlistener event="onkeydown" listener="convertEnter2Tab()" /> </jsfext:inputText> <h:message for="dm"></h:message> </td> <td align="right" style="font-size: 10pt" mce_style="font-size: 10pt"> 拼音头: </td> <td> <jsfext:inputText id="py" size="35" tabindex="5" value="#{dictionaryModel.dictionarySpell}" maxlength="256"> <jsfext:jseventlistener event="onkeydown" listener="convertEnter2Tab()" /> </jsfext:inputText> </td> <div align="center"> <h:commandButton tabindex="8" value=" 保 存 " action="#{dictionaryModel.onMainFormSubmit}" onclick="return check()"> </h:commandButton> </div>

 

修改字典条目:

<jsfext:javascript path="/cn/hnisi/gdrk/sys/zdgl/zdtm/js/Validation.js" /> <td align="right" style="font-size: 10pt" mce_style="font-size: 10pt"> 字典代码: </td> <td> <jsfext:inputText id="dm" size="35" tabindex="4" value="#{dictionaryModel.dictionary.code}" required="true" cnName="字典条目代码" disabled="#{dictionaryModel.bolInput}" maxlength="50"> <jsfext:jseventlistener event="onkeydown" listener="convertEnter2Tab()" /> </jsfext:inputText> </td> <td align="right" style="font-size: 10pt" mce_style="font-size: 10pt"> 拼音头: </td> <td> <jsfext:inputText id="py" size="35" tabindex="5" value="#{dictionaryModel.dictionary.spell}" disabled="#{dictionaryModel.bolInput}" maxlength="256"> <jsfext:jseventlistener event="onkeydown" listener="convertEnter2Tab()" /> </jsfext:inputText> </td> <h:commandButton tabindex="9" value=" 保 存 " id="Save" action="#{dictionaryModel.onMainFormSubmit}" disabled="#{dictionaryModel.bolSave}" onclick="return check()" />

 

Validation.js

 

function check() { var checkSpell = document.getElementById("py").value; var checkCode = document.getElementById("dm").value; var re1=/^[a-zA-Z]+$/; var re2=/^[0-9]+$/; if (!re2.test(checkCode)) { alert("字典代码只能问数字!"); return false; } if (!re1.test(checkSpell)) { alert("拼音头只能为字母!"); return false; } return true; }

你可能感兴趣的:(JavaScript,action,Path)