How to calculate length of input from single line text variable?

Ashwini Jadhao
Giga Guru

HI Community,

I have created "Provide code" as single line text and adding some input in it and now want to calculated length of  "Provide code"  variable's input.

I am doing it in widget.

Could you please help me to get length through widget scripting.

1 ACCEPTED SOLUTION

Anil Lande
Kilo Patron

Hi,

Have you tried using below logic:

var length1 =g_form.getValue('provide_code').length.toString();

or 

var length1 =g_form.getValue('provide_code').length;

 

 

Thanks,
Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

View solution in original post

2 REPLIES 2

AnirudhKumar
Mega Sage
Mega Sage

Give your input type a model value, and access it in your client function.

 

HTML:

<input type="text" class="form-control" ng-model="provideCode" ng-change="c.getCount()"/>

Client Controller:

api.controller=function($scope) {
  /* widget controller */
	var c = this;
	
	c.getCount = function()
	{
		alert($scope.provideCode.length);
	};

	
};

Anil Lande
Kilo Patron

Hi,

Have you tried using below logic:

var length1 =g_form.getValue('provide_code').length.toString();

or 

var length1 =g_form.getValue('provide_code').length;

 

 

Thanks,
Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande