We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36805
    • 354 Posts
    Hi everyone!

    I’m not sure if this has been tried before (Using Evo). I’m wondering whether it would be possible to have simple validation on a TV input to ensure the input is a number.

    I’m looking into possibility to have the most simple (download) webshop where each product is a MODx document with a specific template and associated tv’s (name, description, price). Of course i need to be 100% sure the price is actually a number.

    I have been using ManagerManager for a while and I’m pleased about the required field support and the syncing. But, unfortunately, this it cannot do as it seems.

    If it cannot be done I would need to take a very different approach. Either not validate at all or using a customized html form in the frontend (much like Maxigallery). I would rather avoid this and allow management in QuickManager and full Manager.

    Any help would be greatly appreciated!
      • 16610
      • 634 Posts
      You can do this with a plugin and jQuery (or with some other JavaScript library).

      I don’t have the actual solution for your case but I have done similar plugins:

      // Get event
      $e = &$modx->Event;
      
      // On OnDocFormPrerender event
      if ($e->name == 'OnDocFormPrerender') {
      
          $output = //Inject the JavaScript to validate your TVs
          $e->output($output);
      }
      
        Mikko Lammi, Owner at Maagit
        • 36805
        • 354 Posts
        Thanks for your reply. Though I would have preferred a server side check I suppose this would do.

        I don’t have any experience with this. I’d like a little more info to get me started.

        I suppose I could get the value by using the textfield #id and some jquery. How do I prevent the save button from happening and get my message out until it is correct first? Also what would be the cleanest way of an error message? An alert box is probably not the prettiest smiley
          • 16610
          • 634 Posts
          I would probably do this kind of validation with jQuery / Validation plugin: http://bassistance.de/jquery-plugins/jquery-plugin-validation/

          It has a lot of examples to learn and to get ideas how to implement validation in your case.
            Mikko Lammi, Owner at Maagit