0

function valform()
{
 var name = document.getElementById("username").value;
 var h2 = document.getElementById("height1").value;
 var w2 = document.getElementById("weight1").value;
 var r2 = document.getElementById("txtresult").value;
 
 if( name == ""  || h2 == "" || w2 == "" || r2 == "" )
 {
  alert("Please fill in the blank(s) first");
  return false;
 }
 if(!($('input[type=radio]:checked').size() == 12))
 {
  alert("You must answer all the questions");
  return false;
 }
}

So, basically the code above cannot run in 000webhost.com but can run with XAMPP server. If I click submit when all the radio buttons do not checked, it supposed to show the alert but it just go to another page. I checked all the syntax are correct and still not working. So I wonder why? The link: https://cancertool123.000webhostapp.com/Questionnaire%20(Colon%20Cancer).php

Some explanations will be helpful.

Script47
  • 14,230
  • 4
  • 45
  • 66
Desmond97
  • 37
  • 6
  • Possible duplicate of [How to get Chrome to allow mixed content?](https://stackoverflow.com/questions/18321032/how-to-get-chrome-to-allow-mixed-content) – Script47 Jun 13 '18 at 05:17

2 Answers2

0

Change

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

to

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

As you can see in the Console (press F12 in your website), there is an error:

Mixed Content: The page at 'https://cancertool123.000webhostapp.com/Questionnaire%20(Colon%20Cancer).php' was loaded over HTTPS, but requested an insecure script 'http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'. This request has been blocked; the content must be served over HTTPS.

The problem is you are loading a http file within a https site.

0

You are loading jquery file from http and your website is working on https so change it to this

https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js

it will work

Bhumi Shah
  • 9,323
  • 7
  • 63
  • 104