Search code examples
javascriptjqueryvalidationknockout-validation

how to set company name should start with character javascript validation rule? it can contain Numbers and special characters followed by character


i want to set validation rule for company names which should start with character and it can contain numbers and special characters..

For example:

  1. 360 Angel - should not be allowed

  2. Angel 360 - Allowed


Solution

  • Javascript regular expressions should help

    Documentation:

    http://www.javascriptkit.com/javatutors/redev3.shtml

    Simple example:

    var str = "360 Angel";
    /^[a-zA-Z].*/.test(str); // return false