Notifications
Announcements
No record found.
how to get last 5 character of a field OR how to check "@gmail.com" is present in field using javascript
*This post is locked for comments
Hi Ak,
1. Are you trying to Validate your Email Field, if yes here is the code
function checkEmail(emailField)
{
var email=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([azA-
Z])+/;
if(email.test(emailField))
// alert("true");
return true;
}
2. If you want to check whether text field contains "@gmail.com", then you can use indexOf() javascript function
For reference you can look into this
www.w3schools.com/.../jsref_indexof.asp
Hope that helps
Thanks
Please mark my post as verified if you found it helpful
If you want the last X characters, you can use the string.slice() method.
var myStr = "Hello world!";
var myRes = str.slice(-4);
myRes => rld!
HI AK, Mithilesh has already given the solution if you want to validate email Id. Also if you want to get last five characters of a string, then you should try this.
var member = "My Name is Saroj"; var last5 = member.slice(-5); alert(last5); O/P SarojThanks
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
SA-08121319-0 4
Calum MacFarlane 4
Alex Fun Wei Jie 2