Skip to main content
Participant
May 12, 2020
Question

Lengh calculation and error message

  • May 12, 2020
  • 2 replies
  • 704 views

When using this script I get the error message when I enter in like 3 of the nine numbers I need,

But if i do put in the afterward the 9 numbers the error message does not go away it stays. Also I tried using <= this ths a value reference in Javascrpt am I doing this wrong

Bank_Routing_number is formated as number

 

var cNumString = this.getField("Bank_Routing_Number").valueAsString;

if (cNumString < 9) event.value = " ";

else event.value = "Bank Routing Number Must be 9 Characters";

 

Help would be appricated

This topic has been closed for replies.

2 replies

Inspiring
May 12, 2020

U.S. bank routing numbers on include a self checking number. This  can be used to verify that it is a valid number.

try67
Community Expert
Community Expert
May 12, 2020

A string can't be compared to a number. You need to convert it to a number first, like this:

if (Number(cNumString) < 9) event.value = " ";

try67
Community Expert
Community Expert
May 12, 2020

Sorry, that's not actually the issue in your case. In second look I think the problem is you're comparing the value itself, instead of its length. So use this code, instead:

 

if (cNumString.length < 9) event.value = " ";