variable length restriction and validation

SnowDEV2
Kilo Expert

Hi All,

 

I have a requirement where one variable should accept only numbers and should be limited to 10 characters.

I have wrote a below onchange script to accept only numbers and onload script for field length.

Unfortunately onload script is not working.. any help please........

 

OnChange

 

function onChange(control, oldValue, newValue, isLoading) {

 

      var callBack = g_form.getValue('callback');

 

     

              if(callBack.match(/\D/)){

                     

                      alert('Please enter only numbers!');

                      g_form.setValue('callback,'');

              }

       

     

}

Onload

 

function onLoad() {

  var call_back = g_form.getControl('callback');

      alert(call_back);

  call_back.maxLength = 10;

}

6 REPLIES 6

A single quote is missing before the comma after the word callback.


Dan_Berglin
Giga Expert

Hi,


Make this an onSubmit with a focus and highlight of the field explaining the guidelines for submitting? I dont get the point of onload where it should'nt have been posible posting at the first time?



Kind regards,


Dan Berglin