I seem to be hitting my head on a brick wall trying to get a RegExp rule working in the form validation for a field on my Fomantic form. All the other rules work including custom ones; just not a RegExp one.
The regExp rule should be validating that the input field is a valid currency amount, but when I add the rule the page fails to load with - "Failed to load resource: the server responded with a status of 500 (Internal Server Error)". Take the rule out and the page loads fine.
The RegEx is: ^$(\d{1,3}(,\d{3})*|(\d+))(.\d{2})?$
The rule I am defining (after escaping the \ chars) is: -
form_amount: { identifier : 'form_amount', rules: [
{ type : "regExp[/^\\$(\\d{1,3}(\\,\\d{3})*|(\\d+))(\\.\\d{2})?$/]",
prompt : 'Please enter a valid amount for this transaction'
}
] }
Anyone know what I am doing wrong ?
Thanks
Phil
Well if you are using JavaScript to validate forms you can do the following