Tuesday, September 30, 2014

Validating fields in WrkTaskIP page

Hi,


I was able to get that working, but I believe it is not correct fully.


when the comments field is not added, and reject button is clicked, I am able to get alert "Please enter comments", but after entering comments and again clicking on Reject, is not processing it.


I have used the below code:



$(document).ready(function () {

var buttons = document.getElementsByTagName("input");

var buttonsCount = buttons.length;

for (var i = 0; i <= buttonsCount; i += 1) {

if (buttons[i].value == "Reject") {

buttons[i].onclick = function (e) {

var txtarea = document.getElementsByTagName("textarea");

var txtareaCount = txtarea.length;

for (var i = 0; i <= txtareaCount; i += 1) {

if (txtarea[i].title == "Type comments to include with your response.") {

if (txtarea[i].value == "") {

alert("Please enter Reason");

e.preventDefault();

return false;

}

else {

return true;

}

}

}

};

}

}

});

The reject button is having the control defined, when I see F12




<input style="width: 76px; height: 21px; text-align: center;"
id="ctl00_PlaceHolderMain_XmlFormControl_V1_I1_B7"
class="w_5jghZOsnCxGdM8MP_0 x_5jghZOsnCxGdM8MP_0 a6_5jghZOsnCxGdM8MP_0 aw_5jghZOsnCxGdM8MP_0"
onfocus="return (Button.OnFocus(this, event));"
title="Reject" onclick="return (Button.OnClick(this, event));"
value="Reject" type="button" OriginalId="V1_I1_B7"
FormId="ctl00_PlaceHolderMain_XmlFormControl" ViewDataNode="13"
direction="ltr" wrapped="true" ScriptClass="Button"
buttonid="Approval_btnReject">


Now my code is also adding a onclick event, so I believe it is not working in the "return true".


I am doing this in a copy of the "WrkTaskIP.aspx", which I have refered as the page in VS 2012 workflow.


How to fix this?


Thanks


No comments:

Post a Comment