Hi Here is my code to display the alert box:
var answer = window.confirm ("The registration you have entered is illegal for the uk roads. By clicking ok you are accepting full resposibility for this plate and agreeing to use it for offroad use only.");
if (answer) {
//Tell them its a show plate
$('#numberplateyellow').append(platetext);
$('#numberplatewhite').append(platetext);
$('#illegal').append('Show Plate Not Road Legal');
}else{
$('#illegal').empty();
}
}else{
//Its A Legal Plate
$('#numberplateyellow').append(platetext);
$('#numberplatewhite').append(platetext);
}
I wish for the windows.confirm to contain a checkbox that says check here if you agree to the terms and conditions.
How do i add a checkbox to the window.confirm ?
Thanks
Hi Here is my code to display the alert box:
var answer = window.confirm ("The registration you have entered is illegal for the uk roads. By clicking ok you are accepting full resposibility for this plate and agreeing to use it for offroad use only.");
if (answer) {
//Tell them its a show plate
$('#numberplateyellow').append(platetext);
$('#numberplatewhite').append(platetext);
$('#illegal').append('Show Plate Not Road Legal');
}else{
$('#illegal').empty();
}
}else{
//Its A Legal Plate
$('#numberplateyellow').append(platetext);
$('#numberplatewhite').append(platetext);
}
I wish for the windows.confirm to contain a checkbox that says check here if you agree to the terms and conditions.
How do i add a checkbox to the window.confirm ?
Thanks
Share Improve this question edited Jul 9, 2011 at 5:21 Jonathan Leffler 756k145 gold badges951 silver badges1.3k bronze badges asked Jun 29, 2011 at 13:48 user393273user393273 1,4385 gold badges25 silver badges49 bronze badges 2- What js library are you using? jQuery? – Naftali Commented Jun 29, 2011 at 13:50
- Also your if/elses dont match up at all – Naftali Commented Jun 29, 2011 at 13:52
3 Answers
Reset to default 4You cannot add a checkbox to a confirm. You will have to make your own dialog for that to work.
Here is a fiddle demo using jQuery's dialog: http://jsfiddle/maniator/tRBEt/
You cannot edit default window feature, so there is no way you can add a checkbox in confirm or alert.
So what's the solution:
Implement your own: you may user intercept submit, create a modal pop that contains checkbox etc, whatever you need.
Instead of an alert style box generated in the browser (which is unlikely to support checkbox's unless their is a proprietary browswer way of doing it).... You may wish to consider a modal dialog box as it will give you more control.
A good implementation is jQuery-UI's dialog box: http://jqueryui./demos/dialog/