Regex help needed for form validation
Hello
I was wondering if anyone could help me with the following problem, and if possible, kind of explain what it means too because Javascript is all new to me! I started reading a tutorial on Regexes but then got totally confused!
I have a text box (called 'cost') in a form which needs some validation done on it
1. Although the user is entering in a cost, the value entered must be a whole number ONLY, between 100 and 100000.
2. The user could enter in a ',' or a '£' (i.e. £2,000) but these characters would be ignored.
At the moment my form validation looks like this:
<script language="javascript">
function ProcessForm()
{
if (document.forms['goalform'].elements['cost'].value == "")
{
alert("Please enter how much your goal will cost.");
document.forms['goalform'].elements['cost'].focus();
return false;
}
return true;
}
</script>
I need to incorporate the regex bit into this code so that my cost textfield is checked for the above mentioned validation.
If anyone is able to help, it would be greatly appreciated.
Thanks in advance
Lucy xx
|