Skip to content

Why does this Vue 3 form validation script fail?

I am working on a Users CRUD application with Vue 3. I run into trouble while trying to validate the data in the “Add New User” form. More precisely, I use the function below to make sure no form field is empy: For a reason I could not figure out, the formErrors array looks like this [“The e…

React: Selecting an element by id prints the wrong element

Hello! So, I am working on this list in react, when I add two elements to my list, and remove the first one added, it prints the other element that is left in the list. Is this normal? the ‘id’ is applied on creation of the list element and contains the title + unique ID applied to the object. Not

combine regex to match subgroups in different order

I have a string with may have one of the 2 below structure some examples would be The goal is to match as below I can manage to get the result with 3 regex, but not with 1 How can I get the expected result with a single regex ? Answer Maybe use | to separate possible matches: Also note

Change CSS with JS for a toggled class

I’m learning JS right now, and I trying to do the following: I’m creating an html grid, each cell is marked with a cell class which doesn’t give it a background color. When I mark the cell (i.e by clicking), the JS code adds it a colored class, which gives it background color: Now, I’m…

How to write an XML file with certain format using JS?

I am trying to write an XML document from an HTML form using JavaScript with the following function: JavaScript function: The file that is generated has the following format: I am trying to modify the method in order for the nodes to have the following format: I know that setAttribute() doesn’t work bec…