For instance, $1.50, 1.50, £4, 3.4 should be processed successfully. Where as just $ or % or # or !2.4 or &45 should given an alert ( special characters ) .
Code: ( in JS )
validatePrice : function(price){
var regexPattern = '^(\\$)\[0-9]+(\.\?[0-9]+)?$';
if (document.asset_edit_frm.price.value.search(regexPattern)== -1){
alert('Not a valid currency format ');
document.asset_edit_frm.price.focus();
return false;
}else return true;
}
This will match the pattern you described.
By the way, if this is straight JavaScript, define the regex as follows:
Note the lack of
'