返回确认书""

时间:2014-05-22 01:05:45

标签: javascript jquery html ajax html5

如何让用户在确认书上写一些内容

实施例。 我正在尝试发出警告说“你确定要删除这个名字吗?”

然后用户需要编写

“确定”或“好”

这就是我现在正在使用的。

<a href="deleteCourse.php">"onclick="return confirm('Are you sure you want to delete this name?');" class="deleteColor">Delete</a>

3 个答案:

答案 0 :(得分:4)

我想你想使用提示:

http://www.w3schools.com/jsref/met_win_prompt.asp

也许写下这样的话:

function confirmDelete() {
    var response = prompt("Please type [DELETE] to confirm you want to delete this entry", "Confirm Delete");

    if (response=='DELETE') {
        return true;
    }
}

答案 1 :(得分:3)

将此添加到Ran Charam

else  
  event.preventDefault();

这是你应该看的链接

<a href="deleteCourse.php">"onclick="confirmDelete()" class="deleteColor">Delete</a>

这是.js

function confirmDelete() {
    var response = prompt("Please type [DELETE] to confirm you want to delete this entry");

    if (response=='DELETE') {
        return true;
    }
    else  
        event.preventDefault();


}

答案 2 :(得分:-3)

不幸的是,这超出了我们的控制范围。相反,您必须使用文本字段创建自己的模态窗口。

有关这方面的一些例子,请参阅jquery-ui。