nissan240zx
Programmer
Hello All,
As part of my ongoing validation issues..here is a new one.
Some of my fields in the form are currency fields and need to add some validations around it to make it "dummy proof".
Here is the scenario
For example I want make this field to accept a maximum of 12 numbers (which I believe is fixed by using maxlength=12).
Now on top of that I want to make sure that ofcourse no more that 12 digits are entered and the values are formatted with a script to make the value look like
000,000,000,000
This I accomplished with this code
Now the final question is...I want to add a condition that "perdiods" should be allowed but should not be counted in the allowed 12 digits...
For example if I enter 1111111111.25
The form should accept that as 12 values and not 13.
HELP
Please advice...
Nissan
A good programmer is someone who looks both ways before crossing a one-way street. - Doug Linder
As part of my ongoing validation issues..here is a new one.
Some of my fields in the form are currency fields and need to add some validations around it to make it "dummy proof".
Here is the scenario
Code:
<tr>
<td>Annual Revenue, if known ($):</td>
<td><input type=text style="width: 285px;" class="textbox" name="business_rev" size=20 maxlength="12" value="" onChange="document.frm.business_rev.value=commaSplit(document.frm.business_rev.value);">
</td>
</tr>
For example I want make this field to accept a maximum of 12 numbers (which I believe is fixed by using maxlength=12).
Now on top of that I want to make sure that ofcourse no more that 12 digits are entered and the values are formatted with a script to make the value look like
000,000,000,000
This I accomplished with this code
Code:
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function commaSplit(srcNumber) {
var txtNumber = '' + srcNumber;
if (isNaN(txtNumber) || txtNumber == "") {
alert("That does not appear to be a valid number. Please try again.");
fieldName.select();
fieldName.focus();
}
else {
var rxSplit = new RegExp('([0-9])([0-9][0-9][0-9][,.])');
var arrNumber = txtNumber.split('.');
arrNumber[0] += '.';
do {
arrNumber[0] = arrNumber[0].replace(rxSplit, '$1,$2');
} while (rxSplit.test(arrNumber[0]));
if (arrNumber.length > 1) {
return arrNumber.join('');
}
else {
return arrNumber[0].split('.')[0];
}
}
}
// End -->
</script>
Now the final question is...I want to add a condition that "perdiods" should be allowed but should not be counted in the allowed 12 digits...
For example if I enter 1111111111.25
The form should accept that as 12 values and not 13.
HELP
Please advice...
Nissan
A good programmer is someone who looks both ways before crossing a one-way street. - Doug Linder