> How do I set the 'readonly' attribute for 'input'?
    
    
    input(readonly=toChecked(readonly))
    
    
    Run

> How do I set and get the position of the cursor in a 'textarea'?

You will need to wrap 
[setSelectionRange](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange).
 Probably something like:
    
    
    proc setSelectionRange(elem: InputElement; selectionStart, selectionEnd: 
int) {.importjs: "#.setSelectionRange(#, #)".}
    
    proc setCursorPosition(elem: InputElement; position: int) =
      elem.setSelectionRange(position, position)
    
    
    Run

> How do I simulate the 'type=number' with a 'textarea'?

try
    
    
    textarea:
          proc onkeydown(e: Event; n: VNode) =
            let val = (e.KeyboardEvent).keyCode
            
            if val < 48 or val > 58:
              # it is not a number key
              e.preventDefault()
    
    
    Run

Reply via email to