Jump to content

Tyler

Members
  • Posts

    9
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Tyler's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. I have been pounding my head against a wall on this one. I need to do data validation for two fields in a tabular report data page in two different scenarios. I have been successfully using the following code to validate one field: <script> var nameOfField = "InlineAddWhole_Value_Perc_Split_to_Agent"; document.addEventListener('DOMSubtreeModified', function(){ if(document.getElementsByName(nameOfField)[0]) { document.getElementsByName(nameOfField)[0].addEventListener('change', function(){ var cash= document.getElementsByName(nameOfField)[0].value; if(isNaN(cash)) { alert("You have entered an invalid number in the Split to Agent field. Value must be numeric whole value decimal. Do not include letters or symbols."); document.getElementsByName(nameOfField)[0].value=""; document.getElementsByName(nameOfField)[0].focus(); } else if((cash) < 0) { alert("You have entered an invalid number in the Split to Agent field. Value cannot be a negative amount."); document.getElementsByName(nameOfField)[0].value="0"; document.getElementsByName(nameOfField)[0].focus(); } else if((cash) > 100) { alert("You have entered an invalid number in the Split to Agent field. Percentage value must be entered as a whole value percentage. i.e. 100% = 100 and 50% = 50"); document.getElementsByName(nameOfField)[0].value="100"; document.getElementsByName(nameOfField)[0].focus(); } }); } }); </script> 1st scenario - How do I validate two different fields independently? Basically field "split to Agent" must be between 0 & 100 and field "Agent ID" must be non-zero. 2nd scenario - How do I validate two different fields dependently? IF field "split to Agent" is less than 100 THEN field "Agent ID" must be non-zero. The main issue that I am running into is that I cannot figure out how to do an event listener for more than 1 field at a time. No matter how I have tried to implement it, I can't. I would appreciate any help that I can get here. Is that possible to implement? Is there any way to implement this? Thank you in advanced! Tyler
  2. @Vitalikssssss That is a brilliant approach. Thank you so much for the suggestion and I think it will work perfectly for my needs! I will implement and will post back If i have any difficulties. Out of curiosity though, is there a way to do this with a JS snippet? I would assume we can, but it wouldn't be as neat as what you suggested. Thanks again! Tyler
  3. @CoopperBackpack I do use the inline Add extensively in my App due to easy of workflow needs and visibility of data during entry. As I posted above, I was able to find a solution to the problem (forgot to post about that solution until now ), but now I have a different (but similar) problem that I need to find a solution for. I made a new post here about it and would appreciate any insight you may have into this. https://forums.caspio.com/topic/17111-date-entry-validationlimitation-in-tabular-report-inlineadd/ Thank you for your response earlier. Also thank you @Nuke354 for that helpful link as well. Tyler
  4. Leaving this here for future members. I was able to get the Inline Insert (Add Records) to validate by using the following code. <script> var nameOfField = "InlineAddSplit_Percentage_To_Agent"; document.addEventListener('DOMSubtreeModified', function(){ if(document.getElementsByName(nameOfField)[0]) { document.getElementsByName(nameOfField)[0].addEventListener('change', function(){ var cash= document.getElementsByName(nameOfField)[0].value; if(isNaN(cash)) { alert("You have entered an invalid value in the Split to Agent field. Value must be numeric. Do not include letters or symbols."); document.getElementsByName(nameOfField)[0].value=""; document.getElementsByName(nameOfField)[0].focus(); } else if((cash) < 0) { alert("You have entered an invalid value in the Split to Agent field. Value cannot be a negative or zero amount."); document.getElementsByName(nameOfField)[0].value=""; document.getElementsByName(nameOfField)[0].focus(); } else if((cash) > 1) { alert("You have entered an invalid value in the Split to Agent field. Percentage value must be entered in decimal form."); document.getElementsByName(nameOfField)[0].value=""; document.getElementsByName(nameOfField)[0].focus(); } }); } }); </script>
  5. I am trying to add Javascript to validate/limit the acceptable date range for a tabular inline add. I have tried several suggestions from various forum posts, but cannot get it to work. I started with this code as a form of this does work in a different application (https://forums.caspio.com/topic/16261-validate-field-value-before-submit-in-tabular-search-report-both-table-and-details/). Please help. <script> var nameOfField = "InlineAddDate"; document.addEventListener('DOMSubtreeModified', function(){ if(document.getElementsByName(nameOfField)[0]) { document.getElementsByName(nameOfField)[0].addEventListener('change', function(){ var cash = document.getElementsByName(nameOfField)[0].value; var sDate = new Date(cash); var prevMonday = new Date(); prevMonday.setDate(prevMonday.getDate() - (prevMonday.getDay() + 6) % 7); var nextSunday = new Date(); nextSunday.setDate(nextSunday.getDate() + (0+(7-nextSunday.getDay())) % 7); if (sDate < prevMonday || sDate>nextSunday){ alert("Enter a valid date between the previous Monday and the next Sunday."); document.getElementsByName(nameOfField)[0].value=""; document.getElementsByName(nameOfField)[0].focus(); }); } }); </script>
  6. I am trying to run the following JS to make sure the value in one field has been entered in decimal form, but I can't get it to work. I have tried multiple iterations/adaptions of suggestions I have found on the forums. Any help would be appreciated. Thank you! <script type="text/javascript"> document.addEventListener('BeforeFormSubmit', function () { event.preventDefault(); var a = document.getElementsByName("InsertRecordSplit_To_Agent"); if (a[0].value <=0 || a[0].value >1) { alert('Split to Agent value is not in the correct range. Please enter split percentage in decimal form.'); } else { document.forms["caspioform"].submit(); } }); </script> Forum posts/pages I have tried to use for adaptions/reference https://howto.caspio.com/datapages/ajax-loading/
  7. Thank you! I don't know why I was missing that....Just up way too late and not thinking straight I guess. Thank you again!
  8. In each of my application tables, I have added four fields for created timestamp, created by user ID, updated timestamp, updated by user ID. I am having trouble figuring out how to capture the "updated by user ID" field when I am editing a record from within a tabular datapage (both inline and details view editing). Any help at all would be appreciated!
×
×
  • Create New...