Hi,
thanks to Dave Clark, I am now able to check all my textboxes for the input value.
However, when an error state is raised, the focus is set back to the textbox involved.
This works fine on the very first textbox in the form.
When I trigger an error on the second textbox, it displays the correct error message, but at the same time it displays an error on the next textbox. The next textbox got the focus for a brief second, and therefor thinks the input is not valid.
This is the script I use:
-----------------------------------------------------------------
<SCRIPT LANGUAGE="JavaScript">
function validatehoogte(field) {
var valid = "0123456789"
var ok = "yes";
var temp;
for (var i=0; i<field.value.length; i++) {
temp = "" + field.value.substring(i, i+1);
if (valid.indexOf(temp) == "-1") ok = "no";
}
if (ok == "no") {
alert("Ongeldige invoer ! Alleen cijfers zijn toegestaan");
field.focus();
field.select();
}
var nbr = Number(field.value);
if (isNaN(nbr)
|| nbr < 1800
|| nbr > 4999) {
alert("Ongeldig: waarde ligt tussen 1800 en 4999");
field.focus();
field.select();}
}
</script>
---------------------------------------------------------------------
the lines concerned are
field.focus();
field.select();}
The second textbox expects a value between 0 and 3, the third a value between 200 and 500
Have a look at :
<!-- m --><a class="postlink" href="http://www.motorexpress.be/ubb/index.htm">http://www.motorexpress.be/ubb/index.htm</a><!-- m -->
At the startup form, just press 'VERZENDEN' , and put a value lower than 1800 in the first textbox on the second page
Thanks!
James
thanks to Dave Clark, I am now able to check all my textboxes for the input value.
However, when an error state is raised, the focus is set back to the textbox involved.
This works fine on the very first textbox in the form.
When I trigger an error on the second textbox, it displays the correct error message, but at the same time it displays an error on the next textbox. The next textbox got the focus for a brief second, and therefor thinks the input is not valid.
This is the script I use:
-----------------------------------------------------------------
<SCRIPT LANGUAGE="JavaScript">
function validatehoogte(field) {
var valid = "0123456789"
var ok = "yes";
var temp;
for (var i=0; i<field.value.length; i++) {
temp = "" + field.value.substring(i, i+1);
if (valid.indexOf(temp) == "-1") ok = "no";
}
if (ok == "no") {
alert("Ongeldige invoer ! Alleen cijfers zijn toegestaan");
field.focus();
field.select();
}
var nbr = Number(field.value);
if (isNaN(nbr)
|| nbr < 1800
|| nbr > 4999) {
alert("Ongeldig: waarde ligt tussen 1800 en 4999");
field.focus();
field.select();}
}
</script>
---------------------------------------------------------------------
the lines concerned are
field.focus();
field.select();}
The second textbox expects a value between 0 and 3, the third a value between 200 and 500
Have a look at :
<!-- m --><a class="postlink" href="http://www.motorexpress.be/ubb/index.htm">http://www.motorexpress.be/ubb/index.htm</a><!-- m -->
At the startup form, just press 'VERZENDEN' , and put a value lower than 1800 in the first textbox on the second page
Thanks!
James