开发者

Trouble with executing code if checkbox is unchecked

I need to validate values of a form only if checkbox is unchecked. If it is checked, I will use values added previously. Now the thing is this or any of these code are not working. As I need to validate these values before I redirecting values to another form.

var ui=document.getElementById('same_info').value;
    ui.OnChange = valid;
       function valid()
         {var frmvalidato开发者_开发问答r  = new Validator("myform");
        frmvalidator.addValidation("shipping_first_name","alpha_s","please enter your First Name or full name");
frmvalidator.addValidation("shipping_first_name","req","Please enter your First Name");

}

2.

 if(!document.myform.same_info.checked)

{ alert('infobox  is not checked'); }

I am using Javascript to validate form. Script is fine as it is working perfectly with form elements , whose values are not depending on checking/unchecking of checkbox.


Change:

var ui=document.getElementById('same_info').value;

to

var ui=document.getElementById('same_info');

Also, I'm fairly certain it's onchange, not OnChange -- Javascript is case sensitive.

ui.onchange = valid;

Also note that if the user checks it, and unchecks it, it will still have those validation requirements even though it has been unchecked.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜