javascript - 如何在 joomla 3.2 中运行 jsfiddle 代码

标签 javascript jquery joomla jsfiddle joomla3.2

我试图在我的 Joomla 站点中运行以下代码,但它无法运行。我正在使用 Joomla 3.2 和 code editor JCK但我仍然无法让 HTML 标签正常工作。所以请帮我运行下面的代码:

    $("#text10").keyup(function() {
      $("#text10").blur();
      $("#text10").focus();
    });
    $("#text10").change(function() {
      var name = $('#text10').val();
      var numbers = /^[0-9]+$/;
      var specialChars = "<>@!#$%^&*()_+[]{}?:;|'\"\\,./~`-=";



      if (name == "" || name == " ") {
        //  alert('All Boxes have elements.');
        $("#equal").show();
        $("#equal a").html("please enter account number");

      } else if (name.match(numbers)) {
        $("#equal").hide();
        $("#equal a").html("correct account number"); //  alert('All Boxes have elements.');
      } else if (name.match(specialChars)) {
        $("#equal").show();
        $("#equal a").html("correct account number"); //  alert('All Boxes have elements.');
      } else {
        //  alert('All Boxes have elements.');
        $("#equal").show();
        $("#equal a").html("please check your account number  correctly");

      }

    });
#products {
  font: 13px/20px'Lucida Grande', Verdana, sans-serif;
  color: #404040;
  background: #f2f8fc;
}
.ui-widget-content ul li {
  display: block;
  float: left;
  line-height: 30px;
  list-style: none;
  margin: 0 0px;
  text-decoration: blink;
}
.ui-widget-content {
  min-height: 40px;
}
.hidden {
  visibility: hidden;
}
#equal {
  display: none;
}
#e1 {
  display: none;
}
.button-purple {
  background: #9966cb;
  color: #FFFFFF;
  border-color: #8040be #8040be #733aab;
  background-image: -webkit-linear-gradient(top, #a87dd3, #9966cb 66%, #8f57c6);
  background-image: -moz-linear-gradient(top, #a87dd3, #9966cb 66%, #8f57c6);
  background-image: -o-linear-gradient(top, #a87dd3, #9966cb 66%, #8f57c6);
  background-image: linear-gradient(to bottom, #a87dd3, #9966cb 66%, #8f57c6);
}
.button-purple:active {
  background: #9966cb;
  color: #FFFFFF;
  border-color: #733aab #8040be #8040be;
}
.button {
  position: relative;
  display: inline-block;
  vertical-align: top;
  height: 36px;
  line-height: 35px;
  padding: 0 20px;
  font-size: 20px;
  color: #FFFFFF;
  text-align: center;
  text-decoration: none;
  text-shadow: 0 -1px rgba(0, 0, 0, 0.4);
  background-clip: padding-box;
  border: 1px solid;
  border-radius: 2px;
  cursor: pointer;
  -webkit-box-shadow: inset 0 1px rgba(255, 255, 255, 0.1), inset 0 0 0 1px rgba(255, 255, 255, 0.08), 0 1px 2px rgba(0, 0, 0, 0.25);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.1), inset 0 0 0 1px rgba(255, 255, 255, 0.08), 0 1px 2px rgba(0, 0, 0, 0.25);
}
.button:before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  color: #FFFFFF;
  pointer-events: none;
  background-image: -webkit-radial-gradient(center top, farthest-corner, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0));
  background-image: -moz-radial-gradient(center top, farthest-corner, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0));
  background-image: -o-radial-gradient(center top, farthest-corner, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0));
  background-image: radial-gradient(center top, farthest-corner, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0));
}
.button:hover:before {
  background-image: -webkit-radial-gradient(farthest-corner, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.03));
  background-image: -moz-radial-gradient(farthest-corner, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.03));
  background-image: -o-radial-gradient(farthest-corner, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.03));
  background-image: radial-gradient(farthest-corner, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.03));
}
.button:active {
  -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
  color: #FFFFFF;
}
.button:active:before {
  content: none;
  color: #FFFFFF;
}
.button-pink {
  background: #e8367f;
  border-color: #d31865 #d31865 #bc165a;
  background-image: -webkit-linear-gradient(top, #eb5190, #e8367f 66%, #e62473);
  background-image: -moz-linear-gradient(top, #eb5190, #e8367f 66%, #e62473);
  background-image: -o-linear-gradient(top, #eb5190, #e8367f 66%, #e62473);
  background-image: linear-gradient(to bottom, #eb5190, #e8367f 66%, #e62473);
}
.button-pink:active {
  background: #e8367f;
  border-color: #bc165a #d31865 #d31865;
}
.button-orange {
  background: #f4902a;
  border-color: #df770c #df770c #c76a0a;
  background-image: -webkit-linear-gradient(top, #f69f47, #f4902a 66%, #f38617);
  background-image: -moz-linear-gradient(top, #f69f47, #f4902a 66%, #f38617);
  background-image: -o-linear-gradient(top, #f69f47, #f4902a 66%, #f38617);
  background-image: linear-gradient(to bottom, #f69f47, #f4902a 66%, #f38617);
}
.button-orange:active {
  background: #f4902a;
  border-color: #c76a0a #df770c #df770c;
}
.button-green {
  background: #5ca934;
  border-color: #478228 #478228 #3c6f22;
  background-image: -webkit-linear-gradient(top, #69c03b, #5ca934 66%, #54992f);
  background-image: -moz-linear-gradient(top, #69c03b, #5ca934 66%, #54992f);
  background-image: -o-linear-gradient(top, #69c03b, #5ca934 66%, #54992f);
  background-image: linear-gradient(to bottom, #69c03b, #5ca934 66%, #54992f);
}
.button-green:active {
  background: #5ca934;
  border-color: #3c6f22 #478228 #478228;
}
.button-red {
  background: #d5452f;
  border-color: #ae3623 #ae3623 #992f1f;
  background-image: -webkit-linear-gradient(top, #da5c48, #d5452f 66%, #c73d28);
  background-image: -moz-linear-gradient(top, #da5c48, #d5452f 66%, #c73d28);
  background-image: -o-linear-gradient(top, #da5c48, #d5452f 66%, #c73d28);
  background-image: linear-gradient(to bottom, #da5c48, #d5452f 66%, #c73d28);
}
.button-red:active {
  background: #d5452f;
  border-color: #992f1f #ae3623 #ae3623;
}
.button-gray {
  background: #47494f;
  border-color: #2f3034 #2f3034 #232427;
  background-image: -webkit-linear-gradient(top, #55585f, #47494f 66%, #3d3f44);
  background-image: -moz-linear-gradient(top, #55585f, #47494f 66%, #3d3f44);
  background-image: -o-linear-gradient(top, #55585f, #47494f 66%, #3d3f44);
  background-image: linear-gradient(to bottom, #55585f, #47494f 66%, #3d3f44);
}
.button-gray:active {
  background: #47494f;
  border-color: #232427 #2f3034 #2f3034;
}
.tasks {
  margin: 50px auto;
  width: 240px;
  background: white;
  border: 1px solid #cdd3d7;
  border-radius: 4px;
  -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.ui-widget-header {
  position: relative;
  line-height: 24px;
  padding: 7px 15px;
  color: #5d6b6c;
  align: "center";
  text-shadow: 0 1px rgba(255, 255, 255, 0.7);
  background: #f0f1f2;
  border-bottom: 1px solid #d1d1d1;
  border-radius: 3px 3px 0 0;
  background-image: -webkit-linear-gradient(top, #f5f7fd, #e6eaec);
  background-image: -moz-linear-gradient(top, #f5f7fd, #e6eaec);
  background-image: -o-linear-gradient(top, #f5f7fd, #e6eaec);
  background-image: linear-gradient(to bottom, #f5f7fd, #e6eaec);
  -webkit-box-shadow: inset 0 1px rgba(255, 255, 255, 0.5), 0 1px rgba(0, 0, 0, 0.03);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.5), 0 1px rgba(0, 0, 0, 0.03);
}
.tasks-title {
  line-height: inherit;
  font-size: 14px;
  font-weight: bold;
  color: inherit;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
Payers account number
<input type="text" name="text10" id="text10" size="25" />


<div width="100%" id="equal">
  <a href="#" class="button button-green"></a>
</div>

最佳答案

在您的编辑器上单击左上角的源代码。然后输入此代码:

<div id="custom_form">
    Payers account number
    <input type="text" name="text10" id="text10" size="25" />
    <div width="100%" id="equal"><a href="#" class="button button-green"></a></div>
</div>
<style>
#products{font: 13px/20px 'Lucida Grande', Verdana, sans-serif;
  color: #404040;
  background: #f2f8fc;}
.ui-widget-content ul li
{
    display: block;
    float: left;
    line-height: 30px;
    list-style:none;
    margin: 0 0px;
    text-decoration:blink;
}
.ui-widget-content
{
   min-height:40px;

}
.hidden{
    visibility:hidden;
}
#equal
{display:none;
}
#e1
{display:none;
}
.button-purple {
  background: #9966cb;
     color:#FFFFFF;
  border-color: #8040be #8040be #733aab;
  background-image: -webkit-linear-gradient(top, #a87dd3, #9966cb 66%, #8f57c6);
  background-image: -moz-linear-gradient(top, #a87dd3, #9966cb 66%, #8f57c6);
  background-image: -o-linear-gradient(top, #a87dd3, #9966cb 66%, #8f57c6);
  background-image: linear-gradient(to bottom, #a87dd3, #9966cb 66%, #8f57c6);
}
.button-purple:active {
  background: #9966cb;
     color:#FFFFFF;
  border-color: #733aab #8040be #8040be;
}
.button {
  position: relative;
  display: inline-block;
  vertical-align: top;
  height: 36px;
  line-height: 35px;
  padding: 0 20px;
  font-size: 20px;
  color:#FFFFFF;
  text-align: center;
  text-decoration: none;
  text-shadow: 0 -1px rgba(0, 0, 0, 0.4);
  background-clip: padding-box;
  border: 1px solid;
  border-radius: 2px;
  cursor: pointer;
  -webkit-box-shadow: inset 0 1px rgba(255, 255, 255, 0.1), inset 0 0 0 1px rgba(255, 255, 255, 0.08), 0 1px 2px rgba(0, 0, 0, 0.25);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.1), inset 0 0 0 1px rgba(255, 255, 255, 0.08), 0 1px 2px rgba(0, 0, 0, 0.25);
}
.button:before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
     color:#FFFFFF;
  pointer-events: none;
  background-image: -webkit-radial-gradient(center top, farthest-corner, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0));
  background-image: -moz-radial-gradient(center top, farthest-corner, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0));
  background-image: -o-radial-gradient(center top, farthest-corner, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0));
  background-image: radial-gradient(center top, farthest-corner, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0));
}
.button:hover:before {
  background-image: -webkit-radial-gradient(farthest-corner, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.03));
  background-image: -moz-radial-gradient(farthest-corner, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.03));
  background-image: -o-radial-gradient(farthest-corner, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.03));
  background-image: radial-gradient(farthest-corner, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.03));
}
.button:active {
  -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
     color:#FFFFFF;
}
.button:active:before {
  content: none;
     color:#FFFFFF;
}

.button-pink {
  background: #e8367f;
  border-color: #d31865 #d31865 #bc165a;
  background-image: -webkit-linear-gradient(top, #eb5190, #e8367f 66%, #e62473);
  background-image: -moz-linear-gradient(top, #eb5190, #e8367f 66%, #e62473);
  background-image: -o-linear-gradient(top, #eb5190, #e8367f 66%, #e62473);
  background-image: linear-gradient(to bottom, #eb5190, #e8367f 66%, #e62473);
}
.button-pink:active {
  background: #e8367f;
  border-color: #bc165a #d31865 #d31865;
}
.button-orange {
  background: #f4902a;
  border-color: #df770c #df770c #c76a0a;
  background-image: -webkit-linear-gradient(top, #f69f47, #f4902a 66%, #f38617);
  background-image: -moz-linear-gradient(top, #f69f47, #f4902a 66%, #f38617);
  background-image: -o-linear-gradient(top, #f69f47, #f4902a 66%, #f38617);
  background-image: linear-gradient(to bottom, #f69f47, #f4902a 66%, #f38617);
}
.button-orange:active {
  background: #f4902a;
  border-color: #c76a0a #df770c #df770c;
}
.button-green {
  background: #5ca934;
  border-color: #478228 #478228 #3c6f22;
  background-image: -webkit-linear-gradient(top, #69c03b, #5ca934 66%, #54992f);
  background-image: -moz-linear-gradient(top, #69c03b, #5ca934 66%, #54992f);
  background-image: -o-linear-gradient(top, #69c03b, #5ca934 66%, #54992f);
  background-image: linear-gradient(to bottom, #69c03b, #5ca934 66%, #54992f);
}
.button-green:active {
  background: #5ca934;
  border-color: #3c6f22 #478228 #478228;
}.button-red {
  background: #d5452f;
  border-color: #ae3623 #ae3623 #992f1f;
  background-image: -webkit-linear-gradient(top, #da5c48, #d5452f 66%, #c73d28);
  background-image: -moz-linear-gradient(top, #da5c48, #d5452f 66%, #c73d28);
  background-image: -o-linear-gradient(top, #da5c48, #d5452f 66%, #c73d28);
  background-image: linear-gradient(to bottom, #da5c48, #d5452f 66%, #c73d28);
}
.button-red:active {
  background: #d5452f;
  border-color: #992f1f #ae3623 #ae3623;
}
.button-gray {
  background: #47494f;
  border-color: #2f3034 #2f3034 #232427;
  background-image: -webkit-linear-gradient(top, #55585f, #47494f 66%, #3d3f44);
  background-image: -moz-linear-gradient(top, #55585f, #47494f 66%, #3d3f44);
  background-image: -o-linear-gradient(top, #55585f, #47494f 66%, #3d3f44);
  background-image: linear-gradient(to bottom, #55585f, #47494f 66%, #3d3f44);
}
.button-gray:active {
  background: #47494f;
  border-color: #232427 #2f3034 #2f3034;
}
.tasks {
  margin: 50px auto;
  width: 240px;
  background: white;
  border: 1px solid #cdd3d7;
  border-radius: 4px;
  -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.ui-widget-header {
  position: relative;
  line-height: 24px;
  padding: 7px 15px;
  color: #5d6b6c;
    align:"center";
  text-shadow: 0 1px rgba(255, 255, 255, 0.7);
  background: #f0f1f2;
  border-bottom: 1px solid #d1d1d1;
  border-radius: 3px 3px 0 0;
  background-image: -webkit-linear-gradient(top, #f5f7fd, #e6eaec);
  background-image: -moz-linear-gradient(top, #f5f7fd, #e6eaec);
  background-image: -o-linear-gradient(top, #f5f7fd, #e6eaec);
  background-image: linear-gradient(to bottom, #f5f7fd, #e6eaec);
  -webkit-box-shadow: inset 0 1px rgba(255, 255, 255, 0.5), 0 1px rgba(0, 0, 0, 0.03);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.5), 0 1px rgba(0, 0, 0, 0.03);
}

.tasks-title {
  line-height: inherit;
  font-size: 14px;
  font-weight: bold;
  color: inherit;
}
</style>
<script type="text/javascript"> 
    $("#text10").keyup(function(){
        $("#text10").blur();
        $("#text10").focus();
});
$("#text10").change(function(){
var name = $('#text10').val();
         var numbers = /^[0-9]+$/;   
         var specialChars = "<>@!#$%^&*()_+[]{}?:;|'\"\\,./~`-=";



    if (name == "" || name == " " )
        {
           //  alert('All Boxes have elements.');
             $("#equal").show();
             $("#equal a").html("please enter account number");

        }


    else if(name.match(numbers))
    {
               $("#equal").hide();
             $("#equal a").html("correct account number");   //  alert('All Boxes have elements.');
    }

    else if(name.match(specialChars))
    {
               $("#equal").show();
             $("#equal a").html("correct account number");   //  alert('All Boxes have elements.');
    }
  else 
        {
           //  alert('All Boxes have elements.');
             $("#equal").show();
             $("#equal a").html("please check your account number  correctly");

        }

});
</script>

然后保存您的文章,它应该可以工作。

关于javascript - 如何在 joomla 3.2 中运行 jsfiddle 代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20369626/

相关文章:

javascript - 在一段时间内切换(或闪烁)表中的特定单元格

If Else 语句响应中的 JavaScript For 循环

javascript - 从数组中删除所有没有子元素的元素

mysql - WPMU for Joomla 从 Joomla 1.5 导入数据库记录

javascript 无法在 Joomla 3 上运行

javascript - 当 channel 开始直播时从 Youtube API 获取通知?

javascript - 转换为单词的 Jquery 无法正常工作

javascript - 我想做一个显示百分比的狗计算器

javascript - 获取下拉列表中选定的项目不起作用

joomla - 在 joomla 中返回上一页