onKeyup difficulties with iPad on v2.05

More
3 years 3 days ago - 3 years 3 days ago #107871 by cshaw
cshaw created the topic: onKeyup difficulties with iPad on v2.05
To those with success on iPad's in version 2.05 ... HELP!!! :(

I am using double authentication for surveys.
The user needs a token to get to the survey, per usual.
I use JavaScript to hide the "Next" button when the page with the first question loads.
I also use JavaScript/jQuery to set up a keyup event to call a custom handlekeypress() function.
The first survey question prompts the user to enter a second token into a short text question.
On each keystroke into the question the handlekeypress() funciton is called checking for a match between the token field attribute_1 (token2) and the entered text.
On a match the handlekeypress() function enables the "Next" key and the user can continue on the survey.

In my previous survey in 1.92 this all works great in IE, Mozilla, and Safari on the iPad.

However I am having some difficulty on the Safari browser on an iPad, I don't seem to be able to trigger a keyup event from the touch screen.

I have tried, keyup, keydown, keypress, and change events trying to capture the entry of text, but to no avail. I am pretty sure it is possible ... I just haven't found the magic formula.

I am thinking that this may be because in 2.05 the onkeyup() function for text boxes is already calling the checkconditions() function.

I am going to try dropping the checkconditions() function from the short text answer and then revising the custom handlekeypress() function to call checkconditions() a match is found (no point if the second token is wrong.)

BTW: It is working using just keyup on IE and Mozilla but sadly failing on the iPad ... which is of course where we will delivering it in our waiting room!
Last Edit: 3 years 3 days ago by cshaw.

Please Log in to join the conversation.

More
3 years 3 days ago #107876 by holch
holch replied the topic: onKeyup difficulties with iPad on v2.05
How about installing a different browser on the ipad? Wouldn't that be a possibity? I don't know if Apple allows you to install Chrome, Opera or Firefox...

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds
The following user(s) said Thank You: cshaw

Please Log in to join the conversation.

More
3 years 3 days ago #107878 by cshaw
cshaw replied the topic: onKeyup difficulties with iPad on v2.05
I thought of that, but there are occasions when subjects complete our surveys from home like if they don't have enough time to complete while at their appointment. In that case they could be using an iPad or mobile device, so I felt I needed to thoroughly address the issue.

What I think I am going to do is use jQuery on page load to drop the "onkeyup=checkconditions()" property from the control and then my event code should work. Since I know that the checkconditions code isn't going to do much for this particular question, my requirement that it match the attribute_1 token field is more stringent anyway and it's the only question on the page.

I am thinking that doing that should clear up the issue with the event not firing.

Please Log in to join the conversation.

More
3 years 3 days ago #107888 by tpartner
tpartner replied the topic: onKeyup difficulties with iPad on v2.05
I haven't had time to investigate your keyup problem but how about using JavaScript to, if iPad (or touch device) is detected, insert a "Go" button that can be used to trigger your token-check function?


.

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

More
3 years 3 days ago - 3 years 3 days ago #107911 by cshaw
cshaw replied the topic: onKeyup difficulties with iPad on v2.05
I don't think my solution is particularly elegant but I got the iPad to work correctly by adding the code below to the template.js. I need to do some further testing to make sure that text controls are still getting properly validated. If that fails I will need to strip the checkcondition() from the onkeyup for the specific question, less elegant, but gets the job done, so a work in progress.
/************************************************************/
function handleKeyPress (currval, currname, currtype){
 
    /************************************************************
    /* Custom validation
    /************************************************************/
    if($('token2').length > 0) {
	validateToken2();
    }
 
    /************************************************************
    /* Call default behavior
    /************************************************************/
    checkconditions(currval, currname, currtype);
 
}
 
$(document).ready(function(){
 
    /************************************************************
    /* Remove checkconditions for ALL text box controls
    /************************************************************/
    $("input.text ").each(function(){
        $(this).remove('onkeyup');
    });
 
    /************************************************************
    /* add in an event for the text box keyup
    /************************************************************/
    $('.text ').keyup(function(){
        var currval = $(this).attr('value');
        var currname = $(this).attr('name');
        var currtype = $(this).attr('type');
        handleKeyPress(currval,currname,currtype);
    });
 
});
Last Edit: 3 years 3 days ago by cshaw.

Please Log in to join the conversation.

More
3 years 2 days ago - 3 years 2 days ago #107919 by cshaw
cshaw replied the topic: onKeyup difficulties with iPad on v2.05
This wasn't working like I had thought. So I reworked it. In the end simple is always better. I think this solution works fairly elegantly. :)
/************************************************************/
function handleKeyPress (ctrl, e){ // Inserted Tag Actions
 
    var currval = $(ctrl).attr('value');
    var currname = $(ctrl).attr('name');
    var currtype = $(ctrl).attr('type');
    var needtocheck = e==="onkeyup"; // we only override "onkeyup" events
 
    // validate Lime Id
    if($('idcheck').length > 0) {
        validateToken2();
        needtocheck = true;
    }
 
    if ( needtocheck ) {
        checkconditions(currval, currname, currtype, e); // invoke default text box checkconditions
    }
 
}
 
/************************************************************/
$(document).ready(function(){
 
    /************************************************************
    EVENTS 
    /************************************************************/
    $('.text ').keyup(function(){
        handleKeyPress(this,'onkeyup');
    });
 
});
Last Edit: 3 years 2 days ago by cshaw.

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now