3

My code:

<select class="validate-select" title="subjects" id="subjects1" name="subject" >
    <option value=""><?php echo $this->__("Please select Subject");?></option>
    <option value="english"><?php echo $this->__("English");?></option>
    <option value="maths"><?php echo $this->__("Maths");?></option>
    <option value="science"><?php echo $this->__("Science");?></option>

</select>
<select class="validate-select" title="subjects" id="subjects" name="subjects" >
    <option value=""><?php echo $this->__("--Please select Subject--");?></option>
    <option value="general paper"><?php echo $this->__("General Paper");?></option>
    <option value="biology"><?php echo $this->__("Biology");?></option>
    <option value="chemistry"><?php echo $this->__("Chemistry");?></option>
    <option value="physics"><?php echo $this->__("Physics");?></option>

</select>

Don't know why but i m not getting error message

enter image description here

like this message should be display please select option but i m not getting it how to display message

  • Could you add the form validation script? the above code works for me – saravanavelu Jun 17 '15 at 11:25
  • <script type="text/javascript"> var newRequestTutorForm = new VarienForm('request_tutor', true); </script> this script? another field like text,radio get error message only in dropdown not getting error msg – ND17 Jun 17 '15 at 11:26
  • try the prototype validation. Validation.validate('select-field-id'). Try this to check – saravanavelu Jun 17 '15 at 11:31
  • i try this Validation.validate('subject'); not working.and i m using so many dropdown check my update – ND17 Jun 17 '15 at 11:39
  • if(Validation.validate($('subjects'))){ console.log('true')}else{console.log(false)} Let me know what you get printed in console – saravanavelu Jun 17 '15 at 11:41
1

enter image description here after seeing your code i realize that you are repeating the id element you have same id for both the id must be unique so change one element id to id="subjects1".
hope this will helps. i tested myself and it working..

<form id="request_tutor">
<select class="validate-select" title="subjects" id="subjects1" name="subject" >
    <option value=""><?php echo $this->__("Please select Subject");?></option>
    <option value="english"><?php echo $this->__("English");?></option>
    <option value="maths"><?php echo $this->__("Maths");?></option>
    <option value="science"><?php echo $this->__("Science");?></option>

</select>
<select class="validate-select" title="subjects" id="subjects" name="subjects" >
    <option value=""><?php echo $this->__("--Please select Subject--");?></option>
    <option value="general paper"><?php echo $this->__("General Paper");?></option>
    <option value="biology"><?php echo $this->__("Biology");?></option>
    <option value="chemistry"><?php echo $this->__("Chemistry");?></option>
    <option value="physics"><?php echo $this->__("Physics");?></option>

</select>
<input type="submit" value="submit">
</form>
<script type="text/javascript">
    //< ![CDATA[
        var customForm = new VarienForm('request_tutor', true);
        //]]>
        </script>
  • i change id but not working – ND17 Jun 17 '15 at 11:57
  • check it if you are not repeating on any other select because i tested it and this was problem in your code – Qaisar Satti Jun 17 '15 at 11:58
  • there is no repeat id – ND17 Jun 17 '15 at 12:00
  • id="subjects" id="subjects" check both the select ids – Qaisar Satti Jun 17 '15 at 12:02
  • in my code i m changing id but not working – ND17 Jun 17 '15 at 12:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.