A regular expression of the pattern attribute is required to check the input field, where the value should be the domain name (including Cyrillic) of any level.

An example of checking without Cyrillic:

<input pattern="^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}$"> 

    1 answer 1

    It's bad that the patterns in the input tag (like the regulars in js) do not understand Unicode.

    Here I offer this option as a solution:

     ^(?=[^_]+$)([\wа-яА-ЯёЁ]([\wа-яА-ЯёЁ-]*[\wа-яА-ЯёЁ])*\.)+(?=[^\d]+$)[\wа-яА-ЯёЁ]{2,63}$ 

    To shorten the record, I use the \w metacharacter, which replaces the character set [a-zA-Z\d_] ;

    the construction (?=[^_]+$) needed to exclude the underscore from the available characters (it is included in \w );

    (?=[^\d]+$) - additionally excludes numbers from the top level domain

     <form > Введите имя домена без http://: <input type="text" name="homepage" pattern="^(?=[^_]+$)([\wа-яА-ЯёЁ]([\wа-яА-ЯёЁ-]*[\wа-яА-ЯёЁ])*\.)+(?=[^\d]+$)[\wа-яА-ЯёЁ]{2,63}$" required><br> <input type="submit"> </form> 

    UPD Although you can and so:

     ^([a-zA-Z\dа-яА-ЯёЁ]([a-zA-Z\dа-яА-ЯёЁ-]*[a-zA-Z\dа-яА-ЯёЁ])*\.)+[a-zA-Zа-яА-ЯёЁ]{2,63}$ 

    Only 1 character longer :)

    UPD2 A negative forward lookup gives the shortest regular schedule:

     ^(?!.*_)([\wа-яА-ЯёЁ]([\wа-яА-ЯёЁ-]*[\wа-яА-ЯёЁ])*\.)+(?!.*\d)[\wа-яА-ЯёЁ]{2,63}$