Jump to content

Search the Community

Showing results for tags 'validation'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Caspio Bridge
    • Caspio Apps for Ukraine
    • General Questions
    • Caspio JavaScript Solutions
    • Tables, Views and Relationships
    • Import/Export and DataHub
    • DataPages
    • Deployment
    • Security, Authentications, Roles, SAML
    • Styles and Localizations
    • Parameters
    • API and Integration
    • Calculations and aggregations
    • User JavaScript and CSS Discussions

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


MSN


Website URL


ICQ


Yahoo


Skype


Location


Interests

Found 13 results

  1. I have a text field for entering a mobile number on a submit Data Page. I would like to validate the mobile entered to be in the format 61xxxxxxxxx. Reason is I pass this number through zapper to send SMS updates in twilio to new members with their details. How can I validate the field on submission. I have already set the field to repeat for confirmation and a placeholder in the format I require the mobile, but people still add as for example 0456888222
  2. 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/
  3. I'm trying to do a validation of a combination of fields (if a virtualParam 4 says that a deposit is required, you can't choose cash payment). The choice of cash payment is an InsertRecord field that lives in a drop-down box. Note - cbParamVirtual4 is a Select from a table that is bringing back a Yes/No field - I've already had some fun trying to figure out whether to treat that as 1/0 or Yes/no... The answer was Y/N (not yes/no, just y/n). I've seen several example scripts - both in the footer and in HTML blocks designed to validate fields on a page, but I can't seem to get any of them to validate my page. I've tried this one and this one. I also looked at this one but don't understand it. Nothing I do seems to make the validation fail. I've tried If (1=1) and even tried removing the If statement altogether, but the submission always goes through. My most current code looks like this - would greatly appreciate any suggestions. <SCRIPT LANGUAGE="JavaScript"> function pmt() { var depreq = document.getElementById("cbParamVirtual4").value; var pmtplan = document.getElementById("InsertRecordPaymentMethod").value; if (depreq!='Credit Card'){ alert("Please select Credit Card payment for this service"); return false; } } document.getElementById("caspioform").onsubmit=pmt; </SCRIPT>
  4. Hello Caspio Family, Unfortunately, Caspio doesn't have a feature that would allow validating the date before the Submission Form. The only way I found using Caspio standard features is to show a warning message when the date doesn't fit the condition (e.g. when the date should not be prior to today). You can do that with the help of rules. I will show you an example with two dates 'Start Date' and 'End Date' with conditions: the Start Date shouldn't be prior to today and the End Date should not equal or be before the Start Date. 1) Add 2 HTML blocks beneath each Date field and add a section to each HTML block 2) Inside HTML blocks we need to add some warning message in case the condition is not met 3) Create 2 Rules as on screenshots That solution will show our warning messages, but won't prevent form submission if a user disregards the warning. But if it is necessary to let users submit only correct dates, you can use the second solution with JavaScript: 1. Insert Header&Footer, HTML block 1, HTML block 2, and place them below our Date fields. No need to add extra sections. 2. In the Header enable 'Source' and paste the code:<script>document.addEventListener("BeforeFormSubmit", function (event) {startDate = document.querySelector("#InsertRecordDateStart").value;endDate = document.querySelector("#InsertRecordDateEnd").value;warn1 = document.querySelector("#warning1");warn2 = document.querySelector("#warning2");var today = new Date();var dd = String(today.getDate()).padStart(2, '0');var mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!var yyyy = today.getFullYear();today = mm + '/' + dd + '/' + yyyy;if (startDate < today) {event.preventDefault();warn1.style.display = 'block'} else {warn1.style.display = 'none'}if (endDate <= startDate) {event.preventDefault();warn2.style.display = 'block'} else {warn2.style.display = 'none'}});</script> 3. In the HTML block 1 enable 'Source' and paste:<span id="warning1" style="color:#FF0000;display:none;">Start date cannot be in the past or empty</span> 4. In the HTML block 2 enable 'Source' and paste:<span id="warning2" style="color:#FF0000;display:none;">End date cannot be prior or same as Start date or empty</span> 5. Make sure your datafield 1 and datafield 2 are called 'DateStart' and 'DateEnd' respectively or in the JavaScript added to the Header you need to replace in the linesstartDate = document.querySelector("#InsertRecordDateStart").value;endDate = document.querySelector("#InsertRecordDateEnd").value;to the name of the fields you have. You can test to see how it works on my DataPages: 1st solution with Rules 2nd solution with JS
  5. Hi there, If you need to prevent some actions in your application made not by real people, this post is for you. I am going to explain how easuly add Google reCAPTCHA v2 to any DataPage. All you need is to have a Google account. First, you need to create a key http://www.google.com/recaptcha/admin This is very simple, you just need to type any label yuo wish, choose reCAPTCHA v2 and preferable validation method. I am going to use "I'm not a robot". It is important to add domain of all the websites where you are going to use the DataPage. In case you are going to use only URL deployment option, the domain of your account, like 'AccountName.caspio.com' will be enough. Where 'AccountName' is a name of your Caspio account that you can find following 'Help->About Caspio'. After creating a key you will see your site key that you will need to use later. Second step is to add 2 snippets of code: 1) That part should be added to the Head tag on your own website or to the Header of the Configure Fields screen when you edit your DataPage: <script type="text/javascript"> document.addEventListener("BeforeFormSubmit", function (event) { if(grecaptcha.getResponse().length == 0){ event.preventDefault(); alert('Please pass reCaptcha to verify you are not a robot') } }); </script> <script src="https://www.google.com/recaptcha/api.js" async defer></script> Before pasting do not forget to either uncheck the checkbox 'Enable HTML editor' in the Advanced tab or enable 'Source'. 2) Then you need to add HTML block where you wish reCaptcha to apper on your DataPage and add the next code: <div><div class="g-recaptcha" data-sitekey="YourSiteKey"></div></div> Where 'YourSiteKey' should be replaced with your site key. The last step is to relax and stay assured that no robots will be able to mess up your data.
  6. EDIT: Found out the answer to this question- basically, the point of SMS validation is only to validate that a phone number is real and formatted correctly. I thought it was tied to authentication but it's not.
  7. I am trying to make a simple "Submit a Request" form, which will have fields like first name, Last name, email address, phone number, request, etc. Field names are like C_FirstName, C_Surname, C_Email, C_Phone, C_Request I want to validate text entries in the following fields as follows: First / Last name: No numerical characters are allowed Email Address : authenticate email according to https://www.w3resource.com/javascript/form/email-validation.php mobile no.: formatting and checking as per So far I have the phone script working, but my adaptation of the email script (or the combination of the two in the footer of the form) doesn't check the entry in the Email Address field. Any help sincerely appreciated Floris W3's ValidateEmail Script below: function ValidateEmail(mail) { if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myForm.emailAddr.value)) { return (true) } alert("You have entered an invalid email address!") return (false) } document.getElementById("caspioform").onsubmit=validateEmail;
  8. ANY help would be greatly appreciated!!!! Okay, I have a script that I think should work, but I can't get it to function....Here it is: <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script> <script> $("#caspioform").submit( function() { var selectedopts = $('[name=cbParamVirtual1]').getChildren(); for(i=0;i<selectedopts.length;i++) { if(selectedopts[i].val() == '') { return false; } } }); </script> The script is trying to validate the input (into a text field via barcode scanner) against a hidden dropdown (virtual field "cbParamVirtual1").... Event handler question/issues: CURRENTLY, the barcode scanner, as it scans, it hits "enter" (like a keyboard enter, I think) at the same time submitting the form I need the above code to keep it from submitting if the value isn't in the dropdown Is ".submit" the correct event handler for this? ...or do I use ".keypress"? maybe something else? Location of script question Do I put the script in the form's footer or header...or should I put this in the header of the webpage where it's embeded? I'm confused about when to use the form's header/footer vs the webpage header One more detail that I left out is that I have an iframe code deployed in the footer of the form...it's the only way I could get a report to update as the form (also in an iframe) is submitted....it works well, even though I've read you can't deploy inside another datapage.... that seems doesn't seem to hold true with iframes. However, would I need to change the form name above if I have the 2nd datapage deployed in the footer of the form????
  9. How can I validate a URL in an input page? To make sure it is in a correct format
  10. Hi everyone, can you help me? I want to People submit form person of IT receive mail, he can check yes or no if IT peaple checked yes then mail he's send to one person resposible of app http://howto.caspio.com/tech-tips-and-articles/common-customizations/tech-tip-how-to-validate-a-user-email-address/ i have already saw that, but only one mail is possible for validation. Thanks for your help.
  11. Hi everyone, can you help me? I want to People submit form person of IT receive mail, he can check yes or no if IT peaple checked yes then mail he's send to one person resposible of app http://howto.caspio.com/tech-tips-and-articles/common-customizations/tech-tip-how-to-validate-a-user-email-address/ i have already saw that, but only one mail is possible for validation. Thanks for your help.
  12. I need to ensure that values in a column in a tabular report are between 0 and 100 (They are meant to be a percentage impact figure to be entered by the user). I studied the JS example of creating column totals in a tabular report (see http://forums.caspio.com/index.php/topic/3171-js-calculate-column-sum-in-the-result-page/ ) and modified the code as follows, but I cannot get the script to fire at all. I added a number of debugging statements to no avail. I have tried an "onsubmit" type of call as well, apart from the below example. Ideally there should be a way to fire this at the end of adding / editing each row, but I could live with at the end of the whole page as well. At the end of the Header: <div id="cb_checkImpact"> At the beginning of the Footer: </div> <script> function f_check() { alert('Inside function'); var v_impact = 0; var cas_form = document.getElementById("cb_checkImpact"); if (cas_form.getElementsByTagName("table").length > 0) { alert('Found records'); var cas_rows = cas_form.getElementsByTagName("table")[1].getElementsByTagName("tr"); for(var rowIndex=1; rowIndex < cas_rows.length; rowIndex++) { alert('Inside row loop'); var cells = cas_rows[rowIndex].getElementsByTagName("td"); /* 1 – change value inside brackets to choose column to perform validation */ v_impact = cells[2].innerHTML; alert('Found value:'); alert(v_impact); if ( parseFloat(v_impact) < 0 || parseFloat(v_impact) > 100){ alert('Value in %Impact field must be between 0 and 100'); return(false); } alert('No issues found'); } } alert('About to call function'); f_check(); alert('Finished function'); </script>
  13. Hi everyone, I have found several scripts that do not allow to submit the data if the date is too late (or too early). Is it possible to deny to enter the data, if time is too late? I mean, if the data may be added only before 10 AM, and now is 11 AM, then the data is not added and some error message is displayed? Or more simple script, if the data may be added only before 10 AM, and a user tries to enter "11 AM", then the data is not added and some error message is displayed? Thank you for your time!
×
×
  • Create New...