onChange() to check field value

casey4man
Giga Contributor

Update 8/7:

I had to re-do the script because i was running into issues with the split. When someone used ':' to end their intro to the issue, it would not let them submit. It was also messing with older stories. So this is what I have now but I cannot understand why this will not let me submit at all now. Even when all of the fields are filled in.

function onSubmit () {

var req_keys = [

                          'Instance(s):',

                          'Record(s) used:',

                          'Impacted user group(s):',

                          'Logged in user to view/create issue:',

                          'Steps to reproduce:'

  ];

var array = [];

var desc = g_form.getValue('description');

for (var i = 0; i < req_keys.length; i++); {

if (desc.indexOf(array, req_keys[i]) > -1) {

alert('Please include all template fields in your description:\n\nInstance(s) ->\nRecord(s) used ->\nImpacted user group(s) ->\nLogged in user to view/create issue ->\nSteps to reproduce ->');

return false;

}

}

}

____________________________________________________________________________________________________________________________________________________  

Hi,

I need to check to see if the "description" field has been changed when a user logs and incident. I have 4 fields within the description field that are mandatory to complete before the record can be submitted. I am running into issues trying to figure out how to check if the description field has been filled out completely. I have tried to compare the empty value to the filled value but then i cant submit the form. Any help would be appreciated!

See screen shots below:

find_real_file.png

Here is the client script I currently have:

function onSubmit() {

var description = g_form.getValue('u_description');

g_form.getValue('u_description');

    //Type appropriate comment here, and begin script below

if ( description == 'Instance: +

'\n' + 'Record used:'

'\n' + 'Impacted user group:'

'\n' + 'Steps to reproduce:'); {

alert('Please fill out all description requirements and attach screenshots');

return false;

}

}

1 ACCEPTED SOLUTION

Please check if this helps.



function onSubmit() {


var i;


var description = g_form.getValue('u_description');


var dec_text = description.split('\n');


for(i = 0; i < dec_text.length; i++){


var description_text = dec_text[i].split(':');


if(description_text[1] == ""){


alert('Please fill out all description requirements and attach screenshots');


return false;


}


}


}        


View solution in original post

7 REPLIES 7

That works! Thank you for your help Shishir!


casey4man
Giga Contributor

So now I have a new issue related to the original topic.



When users try to enter in the required information - they can only do it on one line (ie. they cant use a new line). How can I fix this issue?


Hi Casey,



Are you trying to say that users are hitting enter after providing information in one required value, I tried below and it works can you please explain if I am missing anything.



find_real_file.png


find_real_file.png


find_real_file.pngfind_real_file.png