What is JotForm?
JotForm is a free online form builder which helps you create online forms without writing a single line of code. No sign-up required.

At JotForm, we want to make sure that you’re getting the online form builder help that you need. Our friendly customer support team is available 24/7.

We believe that if one user has a question, there could be more users who may have the same question. This is why many of our support forum threads are public and available to be searched and viewed. If you’d like help immediately, feel free to search for a similar question, or submit your question or concern.


  • Profile Image

    Ruby Code validation

    Asked by ugrinoskiwinner on August 09, 2016 at 09:15 AM

    Hi guys,

     

    I have a question wrt verification of a number field (13 digits) with this Ruby code:

    def validjmbg jmbg len = jmbg.scan(/[0-9]/).size valid_chars = (jmbg =~ /^[0-9]+$/) if len!=13 or !valid_chars return false else j = jmbg.split(//).map(&:to_i) v = 11-((7*(j[0]+j[6])+ 6*(j[1]+j[7])+ 5*(j[2]+j[8])+ 4*(j[3]+j[9])+ 3*(j[4]+j[10])+ 2*(j[5]+j[11]))%11) v = 0 if v>9 return v==j[12] end end

    Is it doable?

     

    This is a formula that I've got for validating Unique Citizen Number. 

     

    Thanks

    ruby style size font unique
  • Profile Image
    JotForm Support

    Answered by Nik_C on August 09, 2016 at 11:00 AM

    Regarding the Ruby code, it looks fine, the length is 13, it should be numbers and then, I guess it is some kind of formula to give you the unique 13 digits number.

    Now, this should be doable, but you will have to download the whole source code of your form and do some coding to apply that to a certain field.

    I'm not sure how good are you in coding, but it should be doable.

    If you have further questions please let us know.

    Thank you!