Master Posted July 17, 2018 Report Share Posted July 17, 2018 I want to validate user input to start with 2 letters and follow with 4 numbers when user tries to add data to a submission form Quote Link to comment Share on other sites More sharing options...
MayMusic Posted July 17, 2018 Report Share Posted July 17, 2018 You can have a JS like the example below in the Footer <script> var inputfield= document.getElementsByName('InsertRecordFIELDNAME')[0]; inputfield.onchange= function (){ var str=inputfield.value; if(str.length > 0 && str.length <7) { var res = str.substring(0, 2); var res2 = str.substring(2, 6); if (!/^[a-zA-Z]+$/.test(res)) alert('It should start with 2 letters'); if (isNaN(res2)) alert('It should end with 4 numbers'); } else { alert('the length is exceeding'); } } </script> 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.