#1 by wendy (edited )
Hi, Thank you so much for your help in advance! Here's my setup: There are two fields on the same page: "select1" and "select2". select1 is a radio select with two values: 1, 2. select2 could take any integer between 0 and 40, but would appear only when the subject selected 2 for "select1". I tried to hide "select2" when the value of "select1" is 1 and make it appear when the value of "select1" is 2. I don't know Javascript so I just edited the codes from another project, and it worked in hiding and showing. == Here is the definition for "select2": select2 = models.IntegerField( blank=True, min=0, max=40) === Here is what I had on the HTML file. <div class="form-group" id="select2" style="display: none;"> {{ formfield 'select2' }} {{ formfield_errors 'select2' }} </div> <script> $('#select1 :radio').click(function(){ var d0val=$('input:radio[name="select1"]:checked').val(); if(d0val == 1){ $('#select2').hide(); }else if(d0val == 2){ $('#select2').show(); } }) </script> ===== How it worked: (1) if I enter a number out of the boundary for select2, there would be an error message (2) However, if I don't enter anything, I could proceed to the next page without any alert. Could you please let me know how to give the alert to the missing value? Especially, is it possible to create a var for the value of "select2" and then use the if statement under if(d0val == 2)? Thanks a lot! Best, Wendy