Hi
Can anyone help?
I have a simple contact form which I have so far managed to validate, the one function I do not know how to do is this-
If the browser selects the checkbox I need them to fill out a textfield as well(10 digit number to be exact) or the form doesn’t validate, if they de-select or do not select the checkbox I want the form to validate without it.
Hope that makes sense
Thanks MAC
Validating a textfield once a checkbox is ticked
Started by
Guest_MAC_*
, May 22 2007 06:51 AM
1 reply to this topic
#1
Guest_MAC_*
Posted 22 May 2007 - 06:51 AM
Guest_MAC_*
|
|
|
#2
Guest_Jordan_*
Posted 22 May 2007 - 09:14 AM
Guest_Jordan_*
If you want to do this before the submit button is pressed then you will need to use JavaScript. Here is some sample code:
[COLOR=#ff0000]<script Language="JavaScript">
<!--
function Blank_TextField_Validator()
{
// Check the value of the element named text_name
// from the form named text_form
if (text_form.text_name.value == "")
{
// If null display and alert box
alert("Please fill in the text field.");
// Place the cursor on the field for revision
text_form.text_name.focus();
// return false to stop further processing
return (false);
}
// If text_name is not null continue processing
return (true);
}
-->
</script>[/COLOR]
<form name="text_form" method="get" action="http://www.codeave.com/html/get.asp"
[COLOR=#ff0000] onsubmit="return Blank_TextField_Validator()"[/COLOR]>


Sign In
Create Account

Back to top









