I have the following regular expression to only accept alphanumeric characters and a space char.
/[a-zA-Z0-9 ]*$/
Works fine on my server side validation (c#), however on my client side it's returning true for values like $£"%$£"%^£
.
What gives?
Here's the client side code:
$.validator.addMethod('alphanumeric', function (value, element, regexp) {
if (regexp.constructor != RegExp)
regexp = new RegExp(regexp);
else if (regexp.global)
regexp.lastIndex = 0;
return regexp.test(value);
}, 'Please only enter alphanumeric characters (a-z, 0-9)');
$('#PredictedA2, #GCSE').rules("add", { alphanumeric: /[a-zA-Z0-9 ]*$/ });