Jump to content

Check input + focus next fiels + auto submit


Recommended Posts

Hello,

 

I need some help to automate my form.

  • I use an Bar code scanner which puts an "enter" after the scanned code
  • Both SN (serial numbers) must be the same

 

My process should be the following;

  1. User: scan SN1 (bar code) + enter signal form bar code scanner
  2. System: verify the SN (should have 10 characters)
    1. If correct set focus to SN2
    2. If not correct remove remove input from SN1
  3. User: scan SN2 (bar code) + enter signal form bar code scanner
  4. System:
    1. verify the SN2 (should have 10 characters)
      1. If not correct remove remove input from SN1
    2. Verify if SN1 and SN2 the same
      1. If not give user warning (remove the both SN1 and SN2 input)
      2. if yes enter foam

 

I would appreciate any help how I can realize this.

Thank you in advance

 

 

image.png.5172864588801f2a5c10d762cbb6928d.png

Link to comment
Share on other sites

Hello,

I got it working to some level:

 

<script type="text/javascript">
function stopRKey(evt) {
  var evt = (evt) ? evt : ((event) ? event : null);
  var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
  if ((evt.keyCode == 13) && (node.type=="text"))  {
 sn1 = document.getElementById("InsertRecordSN1").value
 sn2 = document.getElementById("InsertRecordSN2").value
 if (!(sn1.length==10 && sn2.length==10 && sn1==sn2)){
  return false;
 }
   }
  }

  function focussn2()
  {
 sn1 = document.getElementById("InsertRecordSN1").value
  if (sn1.length==10){
     document.getElementById("InsertRecordSN2").focus();
  }
  }
  
  
 
document.getElementById("Submit").style.display = "none";
document.getElementById("InsertRecordSN1").focus();

document.onkeypress = stopRKey;
document.getElementById("InsertRecordSN1").onkeyup = focussn2;


</script>

 

1. Issue:

document.getElementById("Submit").style.display = "none"; will break my code and it does not hide the Submit button

 

2. Issue 

I would like to have warning (maybe some text in red letters) inside the submission foam until my conditions are met. I know I can use the alert function but i dont want to use an pop up.

 

Thank you very much for your help

 

 

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...