Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to unfocus the user from the input box in a confirmation box using Jquery?

I am having a confirmation box with a input field requesting a date. When the confirmation box appears, the input box is in focus. How do I unfocus it? I need to drop down a calendar when I click on the input field. Here is my relevant code:

$(".confirmLink").click(function(e) {
    e.preventDefault();
    var targetUrl = $(this).attr("href");
   document.getElementById('dialog').focus();
    $("#dialog").dialog({
        buttons : {
            "OK" : function() {

                window.location.href =  targetUrl+"/"+"deletedDate"+"/"+document.getElementById('deletedDate').value;
            },
            "Cancel" : function() {
                $(this).dialog("close");
            }
        }
    });

    $("#dialog").dialog("open");
});

function datepicker(){
    $( "#deletedDate" ).datepicker(
    {
        dateFormat: 'yy-mm-dd',
        changeMonth: true,
        changeYear: true,
        showAnim: "slideDown"
    });
}

like image 647
Yasitha Avatar asked Apr 01 '11 05:04

Yasitha


People also ask

How do you remove input field focus?

The blur() method removes focus from an element.

How do you validate input field while Focusout?

The focusout() method in jQuery is used to remove the focus from the selected element. Now we will use focusout() method to validate the input field while focussing out. This method checks whether the input field is empty or not. Also, use some CSS property to display input field validation.

What is blur in jQuery?

jQuery blur() MethodThe blur event occurs when an element loses focus. The blur() method triggers the blur event, or attaches a function to run when a blur event occurs. Tip: This method is often used together with the focus() method.


1 Answers

This should do the trick:

.blur();

(as was pointed out - this is sufficient)

like image 185
Chris McClellan Avatar answered Oct 17 '22 07:10

Chris McClellan