Perzival Posted June 9, 2019 Report Share Posted June 9, 2019 I am looking to implement a simple validation on my form. I would like my user to not submit any numeric value in my submission form. Quote Link to comment Share on other sites More sharing options...
Harbinger Posted June 9, 2019 Report Share Posted June 9, 2019 Hi @Perzival You will need to use JavaScript to check the input then. Use a document selector to get the input element and then check its value attribute. Make sure it is the right length. Then match it against a regular expression. (Learn about them here: Regular Expressions) If everything thing is fine, return true. Otherwise, return false Quote Link to comment Share on other sites More sharing options...
Harbinger Posted June 9, 2019 Report Share Posted June 9, 2019 There is other way to do this, using typeof in JavaScript inside an If block, I believe. I'll get back to you, let me see. Quote Link to comment Share on other sites More sharing options...
Perzival Posted June 9, 2019 Author Report Share Posted June 9, 2019 9 minutes ago, Harbinger said: Hi @Perzival You will need to use JavaScript to check the input then. Use a document selector to get the input element and then check its value attribute. Make sure it is the right length. Then match it against a regular expression. (Learn about them here: Regular Expressions) If everything thing is fine, return true. Otherwise, return false This helps, but I am not fluent in JS, perhaps you can give me an idea on how to integrate regular expression with my form? Quote Link to comment Share on other sites More sharing options...
Harbinger Posted June 9, 2019 Report Share Posted June 9, 2019 25 minutes ago, Perzival said: This helps, but I am not fluent in JS, perhaps you can give me an idea on how to integrate regular expression with my form? Try this: <script type="text/javascript"> document.addEventListener('BeforeFormSubmit', function(event) { event.preventDefault(); var x = document.getElementById('InsertRecordDOM').value; if (typeof x === 'number' || (x%1===0)) { alert('This form only submit alpha characters!'); } else { document.forms["caspioform"].submit(); } }); </script> Perzival 1 Quote Link to comment Share on other sites More sharing options...
Perzival Posted June 9, 2019 Author Report Share Posted June 9, 2019 46 minutes ago, Harbinger said: Try this: <script type="text/javascript"> document.addEventListener('BeforeFormSubmit', function(event) { event.preventDefault(); var x = document.getElementById('InsertRecordDOM').value; if (typeof x === 'number' || (x%1===0)) { alert('This form only submit alpha characters!'); } else { document.forms["caspioform"].submit(); } }); </script> Exactly what I need.. Thank you! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.