Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7941967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:49:36+00:00 2026-06-03T23:49:36+00:00

I am working on an application using MVC 3 and knockoutjs library. Also I

  • 0

I am working on an application using MVC 3 and knockoutjs library. Also I am reseraching the knockout validation plugin. I need to validate an input text value for allowed symbols. As far as I can see, there are not native rules for these so I will have to create a custom one. The bad thing is that my knowledge in regular expressions and javascript is very poor. I need to write a custom function that validates a text box input field and does not allow non-english characters. All the other symbols are permitted. I think I will be able to create the custom rule, but I need the regular expression that validates the input field. Any help with a working example will be greatly appreciated. Thank You!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T23:49:38+00:00Added an answer on June 3, 2026 at 11:49 pm

    does not allow non-english characters

    and

    All the other symbols are permitted

    seems contradicting to me but I’ll try to help 🙂

    First you should consider using Ajax for validation since server-side languages usually have much better support for Unicode. If it’s not an option then first add XRegExp library with Unicode plugin to your page.

    To create a Unicode-aware regular expression use the following form:

    var englishLettersOrSymbols = XRegExp('[\\p{^Letter}\\p{Latin}]*');
    

    Here we say that we accept zero or several (... *) symbols and each symbol is either ([ ... ]) non-letter (\\p{^Letter}) or letter from basic Latin alphabet (\\p{Latin}).

    Now your custom validation rule would look like this:

    ko.validation.rules['englishLettersOrSymbols'] = {
        validator: function(value){
            var rule= XRegExp('[\\p{^Letter}\\p{Latin}]*');
            return rule.test(value);
        },
        message: 'Sorry, {0} this is not valid'
    };
    

    and you would use it in your code like this:

    var vewModel = {
        // ...
        myField: ko.observable().extend({englishLettersOrSymbols: true}),
        // ...
    };
    

    Edit: Removed | from regexp. Thanks, @slevithan. It wasn’t an error per se since \\p{^Letter} already included | symbol and, thus, the regular expression would still work. However, it was quite misleading.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on e-commerce application using asp.net MVC with C#. I need to
I am working on a Facebook tab application. I am using asp.net MVC 2
I'm working on a MVC application in which the Model is implemented using an
Im working on a MVC application, and was just wondering.. Should I be using
I am working on my first ASP.Net MVC Application . I am using Razor
I'm working on a Desktop JavaFX 2 application. We're using FXML, an MVC architecture
My group is working on a new web application and is considering using MVC.
I am working on asp.net mvc application using the mvc2 framework. Here is the
Using MVC, EF 4.2. I am working on an application that has a comment
I'm working on a reporting web application using JasperReport and Spring MVC 3 to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.