1

I need to check to make sure that four fields have some kind of value in them. I have tried these ideas: Check whether a select box is empty How to tell if a DDL has options to select

My code is currently this:

    function goToConfirmStep() {
    var isAllowed = false;
    var type = $(".#tShowingType option:selected").val(); //DDL
    var startDate = $("#startDate").text(); //date picker
    var startTime = $("#startTime option:selected").val(); //DDL
    var endTime = $("showingLength option:selected").val(); //DDL
    if (type.val() ) { //&&   //(type != null || type != "")
    //(startDate.text() == "" || startDate.text() == null)) {//&&
    //($('#startTime').has('option').length > 0) &&
    //($('#endTime').has('option').length > 0)) {
    alert("here");

I left the comments in so you can tell what I have tried.

If they have values selected (which the 'type' and 'startTime' will have one selected on load), I want to move to the next page. I have an alert on the else to prevent them from moving forward if the fields aren't filled out.

Community
  • 1
  • 1
Kevin Fischer
  • 371
  • 7
  • 16

2 Answers2

0

You should not use the && (and) operator because the alert gets displayed only if all the field are empty.

It should be something like:

function goToConfirmStep() {
    var isAllowed = false;
    var type = $(".#tShowingType option:selected").val(); //DDL
    var startDate = $("#startDate").text(); //date picker
    var startTime = $("#startTime option:selected").val(); //DDL
    var endTime = $("showingLength option:selected").val(); //DDL

    if (type == "" || startDate == "" || startTime == "" || endTime == "")
        alert("please fill in the required fields");
    else
        goToNextStep();
}
aleksandar
  • 2,399
  • 2
  • 14
  • 22
0

I eventually had to attack it a different way. This is what I did:

Attacking this from a different angle.

Community
  • 1
  • 1
Kevin Fischer
  • 371
  • 7
  • 16