Notifications
Announcements
No record found.
Hi all,
I have one field vehicle no its allow first alphabets after that numbers and again alphabets any body please help me if u have any code send me..
Thanks
Ravi V
*This post is locked for comments
Hi Ravi,
You can use Regular Expressions to validate a field using JavaScript.
www.w3schools.com/.../jsref_obj_regexp.asp
You will have to experiment with different expressions until you get it right.
Hi Nadeeja,
I am using regular expression but its not working nadeeja if you have any code please send me i am new to mscrm.
Thanks,
Try the following Javascript code.
function VehicleNumberTest() { var vehicleNumberRegularExpression = /[a-z]{2}-\d{2}[ ,][a-z0-9]{1,2}[a-z]-\d{4}|[a-z]{2} \d{2}[ ,][a-z0-9]{1,2}[a-z] \d{4}/i; var vehicleNumber = Xrm.Page.getAttribute("new_vehiclenumber").getValue();//Get value of Vehicle Number field if (vehicleNumberRegularExpression.test(vehicleNumber)) { Xrm.Page.getAttribute("new_vehiclenumber").setValue(vehicleNumber); } else { alert("Type a valid vehicle number"); } }
Hope this helps.
Please try below example.
^[a-zA-Z][0-9]{5}[a-zA-Z]*
^[a-zA-Z] = first character must be a letter
[0-9]{5} = next 5 characters must be numbers
[a-zA-Z]* = everything after that are letters
You can test your regex in below site.
http://regexr.com/
Hi Nithya Gopinath your code is working AP 12 KA 5690 this way but my requirement is AP-02-KA-4678 this way how to modify the code Gopi please help me.
You could try the code below.
For AP 12 KA 5690 format
var vehicleNumberRegularExpression = /[A-Z]{2}[ ][0-9]{2}[ ][A-Z]{2}[ ][0-9]{4}/i;
For AP-12-KA-5690 format
var vehicleNumberRegularExpression = /[A-Z]{2}[-][0-9]{2}[-][A-Z]{2}[-][0-9]{4}/i;
For both AP 12 KA 5690 and AP-12-KA-5690 format
var vehicleNumberRegularExpression = /[A-Z]{2}[ -][0-9]{2}[ -][A-Z]{2}[ -][0-9]{4}/i;
Ya got it Nithya Thank you so much.Give me your id i will send request to you.
I am glad you got it working. Your original question was to match letters (alphabet) numbers and letters (alphabet). AP-02-KA-4678 doesn't match that pattern. It helps if you provide full details of your requirement up front, so the time we spend trying to help you is not wasted.
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