Hi guys,

Im trying to create a custom page in opencart and apply form validation in the same way it works elsewhere in opencart.
But im having trouble getting it to work. I have been cutting and pasting and modifying code to try and get it work but to no avail.

This is the page here http://www.passion4marketing.co.uk/i...&product_id=50

This is the javascript at the bottom of the page

Code:
$('#check-session').bind('click', function() {
       $.ajax({
          url: 'index.php?route=information/order/validateorder',
          type: 'post',
          data: $('#content input[type=\'text\'],'),
          dataType: 'json',
          success: function(json) {
             if (json['error']) {
                if (json['error']['firstname']) {
                   $('#content input[name=\'firstname\']').after('<span class="error">' + json['error']['firstname'] + '</span>');
                }
             }
             else {
             $('#content').hide();
             }   
          }
       });

    });
And this is the function in the controller file

Code:
public function validateorder() {
       
        $json = array();
       
        if (!$json) {               
             if ((utf8_strlen($this->request->post['firstname']) < 1) || (utf8_strlen($this->request->post['firstname']) > 32)) {
                $json['error']['firstname'] = $this->language->get('error_firstname');
             }
        }
        $this->response->setOutput(json_encode($json));
        }
Can anyone help me get this working please ? ???