Page 1 of 1

Form, regex, javascript question

Posted: Sat Jan 23, 2010 9:14 am
by JKM

Code: Select all

<form enctype="multipart/form-data" action="" method="post">
    <strong>Something:</strong> <input type="text" name="f1"><br />
    <strong>Something else:</strong> <input type="text" name="f2"><br />
    <strong>Checkbox data:</strong> <checkbox_data><input type="hidden" value="<checkbox_data>" name="check_data" />
    <div id="checkbox_div">Value1: <input type="checkbox" value="Value1" name="c1"> Value2: <input type="checkbox" value="Value2" name="c2"> Value3: <input type="checkbox" value="Value3" name="c3"> Value4: <input type="checkbox" value="Value4" name="c4"> Value5: <input type="checkbox" value="Value5" name="c5"></div>
    <center><input value="Add" name="submit" type="submit"></center>
</form>
I wan't two things:
1) If you select for example name="c1" and name="c3", <checkbox_data> should be 'Value1, Value3'.
2) - If name="f1" is empty, it should add style="background-color: red;" for the input. It should also add disabled="disabled" to the submit field.
- If name="check_data" is empty, it should add style="background-color: red;" for the div checkbox_div. It should also add disabled="disabled" to the submit field.

Sorry if the explanation is bad :p

Re: Form, regex, javascript question

Posted: Sun Jan 24, 2010 7:41 am
by kaszu
Please post your javascript or is this a question where you want us to write it for you?