web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

I have one field vehicle no its allow first alphabets after that numbers and again alphabets.

(0) ShareShare
ReportReport
Posted on by

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

I have the same question (0)
  • Suggested answer
    Nadeeja Bomiriya Profile Picture
    6,804 on at

    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.

  • Community Member Profile Picture
    on at

    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,

    Ravi V

  • Suggested answer
    Nithya Gopinath Profile Picture
    17,078 on at

    Hi Ravi,

    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.

  • Suggested answer
    Nadeeja Bomiriya Profile Picture
    6,804 on at

    Hi Ravi,

    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/

  • Community Member Profile Picture
    on at

    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.

  • Community Member Profile Picture
    on at

    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.

    Thanks,

    Ravi V

  • Verified answer
    Nithya Gopinath Profile Picture
    17,078 on at

    Hi Ravi,

    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;
  • Community Member Profile Picture
    on at

    Ya got it Nithya Thank you so much.Give me your id i will send request to you.

    Thanks,

    Ravi V

  • Nadeeja Bomiriya Profile Picture
    6,804 on at

    Hi Ravi,

    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.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans