Add javascript control to a field

Add javascript control to a field

dts1dts1 Posts: 22Questions: 0Answers: 0
edited April 2013 in Editor
Hello,
is it possible to add a javascript on a field ?
Exemple, I would like to replace on the fly any "," with a "point" when someone write in a text field. I know that i can do that on server side but I prefer to show to the user that he can't use the ",".
Thanks.

Replies

  • allanallan Posts: 61,438Questions: 1Answers: 10,052 Site admin
    edited April 2013
    You can use the `node` method to get the container node for the field and then operate on it like you would with any other input element ( http://editor.datatables.net/docs/current/Editor.html#node ).

    Example:

    [code]
    $('input', editor.node('myField')).keydown( function (e) {
    // Logic to prevent certain characters
    } );
    [/code]

    Regards,
    Allan
  • dts1dts1 Posts: 22Questions: 0Answers: 0
    Excellent, thanks Allan !
This discussion has been closed.