Page 1 of 1

Field returns undefined

Posted: 17 Feb 2015
by Phoenix
Hi there


I have a 'YesNo' Field and I would like to check if it is selected. I have following code:

fd.field('Other_x0020_baseware_x002d_users').readonly(false);

alert(fd.field('Other_x0020_baseware_x002d_users').value());


I do get undefined as alert...what did I do wrong?

Re: Field returns undefined

Posted: 17 Feb 2015
by Dmitry Kozlov
Hi,

Is it a new, edit, or display form? If the field is rendered in the read only mode, you should use the following code to get its value:

Code: Select all

fd.field('Other_x0020_baseware_x002d_users').control()._el().text()

Re: Field returns undefined

Posted: 17 Feb 2015
by Phoenix
Thanks. It is in the Edit form. Should I then compare it with value 'yes' or 'no' order with boolean oder 0 and 1?

Re: Field returns undefined

Posted: 18 Feb 2015
by Dmitry Kozlov
Could you send HTML-source of your form page to support@spform.com? Thanks!

Re: Field returns undefined

Posted: 18 Feb 2015
by Phoenix
Hi

It works perfect thanks. I compared it with 'Yes' an 'No'

Re: Field returns undefined

Posted: 18 Feb 2015
by Phoenix
hi there..... I have a another problem with multiline rich textfield

although I found this post in the forum it is not working for me.


when i do the following:


fd.field('Justification').control()._el().find('div.ms-rtestate-write').text().replace(/\W/g, '');

if (!fd.field('Justification').control()._el().find('div.ms-rtestate-write').text()) {

....

It will not enter the if statement when Justification is empty. When I add Trim.....it deletes all the text in Justification.... What did I do wrong?

Re: Field returns undefined

Posted: 20 Feb 2015
by Dmitry Kozlov
Please, make sure that you pass the correct internal name of the field into fd.field() method. Also ensure that the type of field is Rich Text, not Enhanced Rich Text or Plain Text.

Re: Field returns undefined

Posted: 20 Feb 2015
by Phoenix
Hello Dimitry


Thanks. I actually do use an enhance richt text field. It works now, when I use this code:

var text = fd.field('Justification').control()._el().find('div.ms-rtestate-write').text().replace(/\W/g, '');

if (text == '') {


...

}


Apparenty, I have to save the result of the method replace in a variable, otherwise it is not working...