AutoComplete suggetions date are not giving the right output

Discussion in 'JavaScript' started by umeshrawat30, Nov 3, 2009.

  1. #1
    In my application java script code having the auto complete event is not there .
    Now we have to handle this.
    Example : suppose the user has enable the name and password in form .
    User has to give dates in the text fields . If user type it then it is fine.


    Next time if he takes the date form the auto suggestion by browser( here my application runs only on the IE) that time it is not giving the right output .

    After choosing the values from the auto suggestions in url date values are null.
    that is why it is not working properly .
    this the code in my file .
    -

    function init()
    {

    if (datatype == "date")
    initDate();

    element.attachEvent("onfocus", onFocus);
    element.attachEvent("onkeypress", onKeyPress);
    element.attachEvent("onchange", onChange);
    if (capacity > 0)
    element.attachEvent("onpaste", onPaste);

    }

    function initDate()
    {

    var img = window.document.createElement("IMG");
    img.src = "../../navistor/common/images/calendar-button.gif";
    img.align = "absmiddle";
    img.onclick = onCalClick;
    img.style.cursor = "hand";
    element.parentElement.appendChild(img);
    element.size = 14;
    element.maxLength = 12;

    //alert("init date "+ "hi");
    }

    function onFocus()
    {
    resetValue = element.value;
    //alert("value is "+resetValue);
    }

    function onKeyPress()
    {
    try
    {
    if (datatype == "caps")
    {
    if (window.event.keyCode >= 97 && window.event.keyCode <= 122)
    window.event.keyCode = window.event.keyCode - 32;
    }
    else if (datatype == "int")
    return window.event.keyCode >= 48 && window.event.keyCode <= 57;
    else if (datatype == "float" || datatype == "double")
    return (window.event.keyCode >= 48 && window.event.keyCode <= 57) || window.event.keyCode == 46;
    else if (datatype == "zip")
    return window.event.keyCode >= 48 && window.event.keyCode <= 57;
    else if (datatype == "zip-ex")
    return window.event.keyCode >= 48 && window.event.keyCode <= 57;
    else if (datatype == "phone")
    return (window.event.keyCode >= 48 && window.event.keyCode <= 57) || window.event.keyCode == 32 ||
    window.event.keyCode == 40 || window.event.keyCode == 41 || window.event.keyCode == 45;
    else if (datatype == "phone-ex")
    return (window.event.keyCode >= 48 && window.event.keyCode <= 57);
    else if (datatype == "ssn")
    return (window.event.keyCode >= 48 && window.event.keyCode <= 57) || window.event.keyCode == 45;
    else if (capacity > 0 && window.event.keyCode >= 32 && window.event.keyCode < 128)
    return element.value.length < capacity;
    }
    catch (e)
    {
    }

    return true;
    }

    there are other method to change the date in differnt formats and for other purposes .

    can you give me some idea how to get the solution for it.
     
    umeshrawat30, Nov 3, 2009 IP
  2. umeshrawat30

    umeshrawat30 Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    if somebody knows the answer
     
    umeshrawat30, Nov 4, 2009 IP