LiveCycle javascript validation -


i have case:

there numeric field, must filled 10 numbered id of user. need have autamatic check of existance of id. formula is: [(p1 * 2) + (p2 * 4) + (p3 * 8) + (p4 * 5) + (p5) * 10) + (p6) * 9) + (p7 * 7) + (p8) * 3) + (p9 * 6)] % 11 = p10 p1 first digit, p2 second etc.

i new in javascript, thankfull help. here i've tried:

if ((((this.position(1) * 2) + (this.position(2) * 4) + (this.position(3) * 8) + (this.position(4) * 5) + (this.position(5) * 10) + (this.position(6) * 9) + (this.position(7) * 7) + (this.position(8) * 3) + (this.position(9) * 6)) % 11) == this.position(10)) {  } else { xfa.host.messagebox("wrong id", "error!", 1, 0); } 

something work:

var s = this.rawvalue; var prod = s.substr(0,1)*2 + s.substr(1,1)*4 + s.substr(2,1)*8 +... if (prod%11 == s.substr(9,1)){    //do whatever } else {    //do whatever else } 

remember substr() function starts @ 0 instead of 1, , second 1 makes sure take 1 character.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -