max length on a number field

ngogte

21-01-2018

I have created a adaptive form with both text and number field (zipcode). maxlength works on the text but not on the number field.

When I set maximum characters in the field configuration, I am able to restrict the length on both the fields.

But because I need different character count for different countries on the zipcode, I cannot use the field configuration as it is setting the maximum for all countries.

I am using a rule editor and using the below configuration:

if (this.value == "US") {

   document.getElementById("guideContainer-rootPanel-panel_1487583818-guidetextbox_1992592829___widget").type="text";

   document.getElementById("guideContainer-rootPanel-panel_1487583818-guidetextbox_1992592829___widget").maxLength=5;

}else if (this.value){

    document.getElementById("guideContainer-rootPanel-panel_1487583818-guidetextbox_1992592829___widget").type="text";

document.getElementById("guideContainer-rootPanel-panel_1487583818-guidetextbox_1992592829___widget").maxLength=10;

}

-----------------------

If anybody can help me how to set the maximum length on the number I will really appreciate it.

Thanks,

Neil

Accepted Solutions (1)

Accepted Solutions (1)

James_R_Green

21-01-2018

Hi Neil,

You can access the fields by name via JS on a form. For example, if your field is called 'country' then 'country.value' will contain the current value and 'this.value' will contain the value of the current field, so you shouldn't need to find them by id.

You may know this already but you can add a 'debugger;' statement into the form JS and step through it in inspector.

With regards to the actual problem you are trying to solve, I don't think you can change the maximum length/validation expression of the field programatically (setting validatePictureClause and maximum didn't work for me).

Unless anyone else replies and knows of a way to change the validation expression/maximum length, would having a few fields with different validation work?

That way you could show/hide them based on the logic you need - it would also have an advantage that you could easily vary the title as well. e.g. UK "Post Code"

P.S. if anyone from Adobe reads this - Is the guidebridge documentation for setProperty wrong?

Adaptive Forms Class: GuideBridge

guideBridge.setProperty(["SOM_OF_FIELD_1"]
                         "visibility"
                         [false]);

I think it is missing two commas between the parameters and also the property looks to be called 'visible' as opposed to 'visibility' e.g:

guideBridge.setProperty(["guide[0].guide1[0].guideRootPanel[0].zip[0]"],

                         "visible",

                         [false]);

Thanks,

James

Answers (0)