duanfu1873 2014-09-04 03:45
浏览 51

如何根据存储在cookie中的值进行验证

http://jsbin.com/viraqixicigi/1/edit?html,css,js,output

Here, I am saving input in cookies. When I re-open it will show all the data I enter. My question is when I enter wrong data, the input turns red, but when I close and reopen the file the wrong input is not red. Can any one help? Thank you.

//save as cookies var formsave1=new autosaveform({ formid: 'save', pause: 1000 //<--no comma following last option! })

  • 写回答

1条回答 默认 最新

  • dongqiangse6623 2014-09-04 04:05
    关注

    To get your code working - try moving your validation code after your autosaveform function call e.g.

    //save as cookies
    var formsave1=new autosaveform({
        formid: 'save',
        pause: 1000 //<--no comma following last option!
    });
    
    //this code is after...
    if(document.getElementById(id).value.toUpperCase()==(id)){
        document.getElementById(id).style.backgroundColor = "green";
    } else {
        document.getElementById(id).style.backgroundColor = "red";
    }
    

    I am curious however, how your form validation is being called when you change input - seems like you want to move that into a function and call it from the cc function when the input changes or when the form is submitted.

    评论

报告相同问题?

悬赏问题

  • ¥15 yolov8边框坐标
  • ¥15 matlab中使用gurobi时报错
  • ¥15 WPF 大屏看板表格背景图片设置
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真