Form, regex, javascript question

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
JKM
Forum Contributor
Posts: 221
Joined: Tue Jun 17, 2008 8:12 pm

Form, regex, javascript question

Post 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
User avatar
kaszu
Forum Regular
Posts: 749
Joined: Wed Jul 19, 2006 7:29 am

Re: Form, regex, javascript question

Post by kaszu »

Please post your javascript or is this a question where you want us to write it for you?
Post Reply