Regarding Modding the source JS to accomodate Custom Verification

  • Profile Image
    Asked on January 10, 2013 at 12:20 PM

    Hey, I've been trying to modify the source javascript (jotform.js) to perform a check digit for Mod 11, so far with no luck.

    The checks should be performed at any alphanumeric field. 

    I am totally open toward any solution you may provide. 

    the following code involves the Mod 11 checks meant to verify NRIC identification codes:


    function chkalphanumeric(alphanumeric) {

    if (alphanumeric.length != 9) return false;

    alphanumeric = alphanumeric.toUpperCase();

    var alphanumericPrefix = alphanumeric.charAt(0);

    if (alphanumericPrefix=='S' || alphanumericPrefix=='F') var sum = 0;

    else if (alphanumericPrefix=='T' || alphanumericPrefix=='G') var sum = 4;

    else return false;

    var aryWeight = new Array(2, 7, 6, 5, 4, 3, 2);

    if (alphanumericPrefix=='S' || alphanumericPrefix=='T') var aryAlpha = new Array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'Z', 'J');

    else if (alphanumericPrefix=='F' || alphanumericPrefix=='G') var aryAlpha = new Array('K', 'L', 'M', 'N', 'P', 'Q', 'R', 'T', 'U', 'W', 'X');

    else return false;

    for (var i=1; i<=7; i++) {

    var currDigit = Number(alphanumeric.charAt(i));

    sum += currDigit*aryWeight[i-1];


    var chkDigit = 11 - (sum%11);

    if (aryAlpha[chkDigit-1]==alphanumeric.charAt(8)) return true;

    else return false;


    Thanks for the help! 
  • Profile Image
    Answered on January 10, 2013 at 01:04 PM

    Hi there, 

    can you please expand on what you are looking to accomplish?

    There may be a way around this that may not include the editting of the JS file.

  • Profile Image
    Answered on January 10, 2013 at 01:41 PM

    Hey Eduardo, 

    I've been trying to get a NRIC (alphanumeric) validation field, to check against a Mod 11 Javascript validation, so in the event of a false return, it will trigger an error message and prevent submission. 





    NRIC Validation, with Regex

  • Profile Image
    Answered on January 10, 2013 at 02:02 PM

    In order for you accomplish such validation, you'll need to get the ID of the field in the form

    For example on this form, it will validate 10 digits. And here you have the code for it


    <script type="text/javascript">

    (function () {
    var accountNum = document.getElementById("input_5"),
    valid = /^[0-9]{10}$/;

    accountNum.onblur = function () {
    if (valid.test(accountNum.value) === false) {
    alert("Please enter a ten (10) digit number!");
    accountNum.value = "";


    Where input_5 is the textbox field that is triggered into the variable var accountNum
    within function() , and the event accountNum.onblur is what makes the trick

    With this solution, there's no need to set numeric validation in the form builder, the script takes care of that.

    You have to paste that script into the body of the webpage, after the form's source code, just before the web page's closing body tag

  • Profile Image
    Answered on January 10, 2013 at 02:05 PM

    I forgot to mention that this workaround was taken from a solution that was originally given by another supporter, on this thread

    What I did is just to explain further how that script work