Unable to get value of readonly field

I am able to get field’s value using

$("select/input/textarea[data-fieldname='fieldname']").val();

But I’m having issue when fetching a read-only field. Its giving underfined.

But when I’m using

$("[data-fieldname='fieldname']").text();

Its giving the value but with other parameters/ spaces too.

Can anyone tell me how to get the value of readonly field using .val (jquery)

PS–> I tried using readonly/readOnly/read-only/input[readonly] but none of them worked

did you try this?
var val = cur_frm.doc.fieldname;
alert(val);

already achieved…thanks btw

if you are using in doc

$(“[data-fieldname=‘workflow_stage’]”)[0].fieldobj.value

:slight_smile:

this didn’t worked but giving error @AkshayJadhao

where are you using on form or in page?

Trying at form

image

this worked for me

$(this)[0].cur_frm.fields_dict.workflow_stage.value

workflow_stage= your field name

can you try this ?

:slight_smile:

Yeah it is working the way you said (in console) but my aim was to access it via custom script. On using this through custom script, its giving error