dousong4777 2013-02-01 17:40
浏览 42

在fieldset中添加验证消息而不是js popup

I have a php app, that has been pieced together, but I am working on an crazy validation piece, that i've got working. At the end of the validation, the following function runs and gives me a popup with the listed of required fields.

function showReqFlds(emptyFlds) {
    for (var i = 0; i < emptyFlds.length; i++) {
    var holdErrMsgs = emptyFlds[i]+' is required.' + "


Works great, but now I want instead of the javascript popup box, I want the error messages to appear in a fieldset at the top of my form.


User opens form, error fieldset is not displaying User clicks the submit button to submit form, but has not filled in a couple of the required fields Error fieldset appears, shows required field list, form is not submitted.

Any assistance would be appreciate. Thank you.

  • 写回答

2条回答 默认 最新

  • doulei8861 2013-02-01 18:29

    Just think about this:

    function changeText(text)
    elem = document.getElementById('error_message');
    elem.innerHTML = text;

    And you have in your html page this:

     <div id='error_message'>I'm a error message</div>      
     <button onclick="changeText('error1');">error1</button>
     <button onclick="changeText('error2');">error2</button>

    With something like this you should do the trick.


    本回答被题主选为最佳回答 , 对您是否有帮助呢?



  • ¥20 管道轴向耦合水击问题
  • ¥60 补全networkx TODO部分。
  • ¥15 有内推吗,云计算linux运维方向
  • ¥30 sort cuteSV.vcf by bcftools用IGV可视化出现报错
  • ¥100 SOS!对STK中导出的天体图像进行质心提取有没有人做过啊
  • ¥15 python 欧式距离
  • ¥15 运行qteasy报错
  • ¥15 遗传算法解决有工序顺序约束的大规模FJSP问题
  • ¥15 企业消防水炮塔设计方案
  • ¥20 WORKBENCH网格划分