Input fields that refuses user to submit website with a lower pagerank than X

So should be smth like
<script type=“text/javascript”>
$.get(“getpagerank.php”, function(data) {
if (getPagerank($url) < 2)
alert(“Pagerank Is Smaller than 2”);
});
</script>

and on the input field i need to add smth like <input onfocus ?
I really appreciate your help, sorry for being a noob in jquery /php.

function checkPR() {
  //edit this
  var $btn = $('#your_submit_button_id');
  var $input = $('#your_url_input_id');

  //do not edit below unless you know what are you doing
  var url = $.trim($input.val());

  $.get('getpagerank.php?url='+url, function(data){

    var pr_int = parseInt(data);

    if ($.trim(data) == '' || pr_int < 2)
    {
      alert('PageRank of this page is less than 2!');
      $btn.attr('disabled', 'disabled');
    }
    else
    {
      $btn.removeAttr('disabled');
    }

  }, 'text');
}

Then call this function whenever your input loses focus for example: <input onblur=“checkPR()” />

Or you can modify it a little bit and call it when submit button is clicked.

I have added this

<script type=“text/javascript”>
function checkPR() {
var $btn = $(‘#buttonsubmit’);
var $input = $(‘#urlpr’);
var url = $.trim($input.val());

$.get(‘getpagerank.php?url=’+url, function(data){

var pr_int = parseInt(data);

if ($.trim(data) == '' || pr_int &lt; 2)
{
  alert('PageRank of this page is less than 2!');
  $btn.attr('disabled', 'disabled');
}
else
{
  $btn.removeAttr('disabled');
}

}, ‘text’);
}
</script>

and it’s sending me this errors.

(256) TPL: [in webmaster/submitWebsite.tpl line 26]: syntax error: var function does not exist (class.compiler.php, line 501) class.template.php line 703 2-7-13 9:14

FrontController->dispatch() # line 18, file: /home/blowhits/public_html/index.php
Controller->render() # line 225, file: /home/blowhits/public_html/core/FrontController.php
TemplateLiteView->render(Object:WebmasterController) # line 167, file: /home/blowhits/public_html/core/Controller.php
Template_Lite->fetch(“webmaster/submitWebsite.tpl”) # line 77, file: /home/blowhits/public_html/views/TemplateLiteView.php
Template_Lite->_fetch_compile(“webmaster/submitWebsite.tpl”, null) # line 360, file: /home/blowhits/public_html/components/template_lite/class.template.php
Template_Lite_Compiler->_compile_file("{capture assign=“headData”}
<META NAME=“ROBOTS” CONTENT=“NOINDEX…”) # line 528, file: /home/blowhits/public_html/components/template_lite/class.template.php
Template_Lite_Compiler->_compile_tag(“var $btn = $(‘#buttonsubmit’);
var $input = $(‘#urlpr’);
var…”) # line 187, file: /home/blowhits/public_html/components/template_lite/class.compiler.php
Template_Lite_Compiler->_parse_function(“var”, null, “$btn = $(‘#buttonsubmit’);
var $input = $(‘#urlpr’);
var url…”) # line 243, file: /home/blowhits/public_html/components/template_lite/class.compiler.php
Template_Lite->trigger_error(“var function does not exist”, “256”, “/home/blowhits/public_html/components/template_lite/class.compil…”, “501”) # line 501, file: /home/blowhits/public_html/components/template_lite/class.compiler.php
trigger_error(“TPL: [in webmaster/submitWebsite.tpl line 26]: syntax error: var…”, “256”) # line 703, file: /home/blowhits/public_html/components/template_lite/class.template.php

Do not put this in a PHP code. This is JavaScript code that has nothing to do with PHP. I have no idea why is your php trying to parse this code…?

So where should i add it? In a Jacascript like checkpr.js ? and after include it in the .tpl file?

I have added it in a .js file, and it’s working properly. Thanks a lot, is there any way that i can submit feedback or help you in any matter.
Also thank you Paul, same thing.

You’re welcome! I don’t need anything, just let me submit my website in your directory :stuck_out_tongue:

P.S. If you’re using Smarty or similar template engine, you must put <script> tags between {literal} and {/literal} so Smarty won’t parse it.

Did not knew this.
Please let me know what website you wish to submit, cubescripts.com? I will submit it myself from the back end.