Jump to content

Validate user input to start with 2 letters and follow with 4 numbers


Recommended Posts

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>

 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...