Jump to content

Can NOT submit by enter key


Recommended Posts

I have this JS code in footer:

<SCRIPT LANGUAGE="JavaScript">
function checkSubmit(){
var idvalue = cbParamVirtual4.value;
var valuesize = idvalue.length;
if (valuesize == 6) {
cbParamVirtual2.value = idvalue;
return true;
} else if (valuesize = 10) {
cbParamVirtual3.value = idvalue;
return true;
    }
return false;
}
document.forms[0].onsubmit=checkSubmit;
</SCRIPT>
 
But for some reason, when there is this code, I can not submit the datapage just by pressing the ENTER key. 
If I remove the JS code, everything goes just fine.
 
where could the problem be? 
 
thanx for any help.
 
 
Link to comment
Share on other sites

On 8/7/2017 at 1:56 PM, Lukas said:

I have this JS code in footer:

<SCRIPT LANGUAGE="JavaScript">
function checkSubmit(){
var idvalue = cbParamVirtual4.value;
var valuesize = idvalue.length;
if (valuesize == 6) {
cbParamVirtual2.value = idvalue;
return true;
} else if (valuesize = 10) {
cbParamVirtual3.value = idvalue;
return true;
    }
return false;
}
document.forms[0].onsubmit=checkSubmit;
</SCRIPT>
 
But for some reason, when there is this code, I can not submit the datapage just by pressing the ENTER key. 
If I remove the JS code, everything goes just fine.
 
where could the problem be? 
 
thanx for any help.
 
 

Hi Lukas,

I believe that you have encountered an issue because you are referencing the Virtual field with incorrect syntax, hence your function returning "False".  

You may try to use following Javascript:

<SCRIPT LANGUAGE="JavaScript">

function checkSubmit(){

var idvalue = document.getElementById(“cbParamVirtual4”).value;
var valuesize = idvalue.length;
if (valuesize == 6) {
document.getElementById(“cbParamVirtual4”).value = idvalue;
return true;
} else if (valuesize == 10) {
document.getElementById(“cbParamVirtual4”).value = idvalue;
return true;
    }
return false;
}
document.forms[0].onsubmit=checkSubmit;
</SCRIPT>

Hope this helps.

Link to comment
Share on other sites

Hello Vitali

I tried your JS code, and it is still not working.

The code works, actually it did also with my old version. If there is 6 lenght size, the JS does its work and insert the value in cbParamVirtual3. If there is 10 lenght size, also JS inserts the value in cbParamVirtual2.

but I still have to press "submit" button, and enter key does not work.

I also tried it on diferent types of browser, no success.

 

 

 

Link to comment
Share on other sites

18 hours ago, Lukas said:

Hello Vitali

I tried your JS code, and it is still not working.

The code works, actually it did also with my old version. If there is 6 lenght size, the JS does its work and insert the value in cbParamVirtual3. If there is 10 lenght size, also JS inserts the value in cbParamVirtual2.

but I still have to press "submit" button, and enter key does not work.

I also tried it on diferent types of browser, no success.

 

 

 

Hi Lukas,

This part of the logic expression of your code has assign operator "=" i.o. equality check operator "==", hence this block will not execute even if valuesize variable equal 10.

else if (valuesize = 10) {
cbParamVirtual3.value = idvalue;
return true;
    }

You may try to use this code:

<SCRIPT LANGUAGE="JavaScript">
function checkSubmit(){
var idvalue = document.getElementById("cbParamVirtual4").value;
var valuesize = idvalue.length;
if (valuesize == 6) {
document.getElementById("cbParamVirtual2").value = idvalue;
return true;
} else if (valuesize == 10) {
document.getElementById("cbParamVirtual3").value = idvalue;
return true;
    }
return false;
}
document.forms[0].onsubmit=checkSubmit;
</SCRIPT>

 

Hope this helps.

Link to comment
Share on other sites

Vitali, I checked the code of yours with mine, and the operator I am using is ==

my code is the same as yours, code works, but only with hitting the submit button.

if I press enter key, nothing happens.

there might be something other going on. I have 3 datapages deployed on my webpage.

If there are 3 datapages, I can not submit by enter key, only by pressing the submit button. but if I deploy only the single datapage which contains the JS code, everything works ok also with enter key.

is there something going on just because I have more than 1 datapage deployed?

 

Link to comment
Share on other sites

Vitali, 

I found out that the javascript on my webpage is probably not a problem.

I have some other datapages deployed where there is no Java Script code.

if there is one datapage deployed, submiting by enter key is not a problem.

but if there is more then 1 datapage deployed, I just cant submit by enter key.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...