I have 2 password fields…Second field is to make sure that each match each other.
I am using regular expression for validation of the password in the first field (for simplicity pattern=“[a-zA-Z]”.
How would I validate second password input to match the first one in order to receive valid or invalid state?
I don’t think that’s possible without Javascript. Also, doing password validations on client side is dangerous. Anyone can modify it. If for example, the HTML or Javascript element has an attribute like required, I can simply remove that with my Inspect Tools option. Then send data empty data or data that you don’t want to your database. So for instance, if you’re looking for only letters in your password. I can simply modify the HTML or Javascript, remove that requirement attribute and then pass numbers with letters into the text field.
You should be validating on the server-side instead.
IMO, you don’t need to do any fancy validations on the client side at all. Doing validations on your server-side is more safer because they cannot modify the server-side codes.
like everyone says client side security check is unsafe as it can be disabled or tampered with so to use validation using PHP is a good server side security besides judging from the password thing I’d assume you are using database, So PHP works well with MYSQL so definitely something to look into
In theory you would simply check that the code in input fields are filtered to check for empty fields, to remove any html tags or “/.,” etc than to validate the second form would be to link the first input field with the second maybe in a form of a single function or linking functions after one another but just like javascript applying a variable toone input can be done the same to the second input field than use a if function to determine “if a=B” that is simplest sorry for not having any code as I am not a programmer wiz but in theory thats how I would see It I do use PHP but been awhile since I used it so refreshing my memory could help lol.
You can’t check the two values match on the client side without js, so you will have to rely on the server side to do it, which you should have already.
The built in browser validation only does simple things like required, min/max/ length, patterns, etc.
It won’t do things where different inputs depend upon each other, that needs scripting.