I'm not massively experienced with JS, but have some experience with php so can read the code reasonably well.
I'm looking to make both fields on my html form required, just a simple alert window would do the trick. I've tried a few simple examples, but they don't seem to work with my form, I think it's because I have a little JS in the form itself, which could be conflicting.
The OP is using event handlers that restore empty fields to initial value, so just checking for "" or null isn't going to be appropriate.
What if password == " " ?
Thanks for the replies. The first code didn't seem to do anything for me.
The second is in PHP, which although is much more understandable for me, unfortunately not what I need. I want the form to check for valid fields before the post action is taken...
The OP is using event handlers that restore empty fields to initial value, so just checking for "" or null isn't going to be appropriate.
What if password == " " ?
This is exactly my problem, and what was I was looking for some direction on...
I'm not massively experienced with JS, but have some experience with php so can read the code reasonably well.
I'm not sure you even know what php code is. Where is the php code you claim to see in your last post?
I posted javascript code enclosed in php formatting tags which is what I have done in probably 99% of my posts.
In your first post you asked that fields be only required. Now you want them to be checked for validity, but you didn't specify what criteria will make each input valid. I'm not going to waste time making assumptions on what you would consider a valid input so I included a comment in my code saying you can add your own additional criteria.
If you need additional direction, it is quicker and easier for me to refer you to the relevent w3school tutorials where you can learn all the skills you will need rather than spoon feed code.
Apologies tirna, for not making myself clearer. Indeed as I look back I got confused by the PHP opening tags (which I have never seen in your posts as I haven't subscribed to your wisdom). I did claim in my first post that I can read some PHP, but obviously, as everyone knows, we all start somewhere and I'm not as advanced as you.
I did even try and make the point about validity when I stated
I think it's because I have a little JS in the form itself, which could be conflicting.
Excuse my ignorance if I didn't refer to this as 'validity'.
I appreciated your first post for trying to help me out, however I didn't see the need to make me feel smaller than you.
I'm get pretty sick of joining forums, trying to be as informative as possible, and getting made to feel bad for asking the initial question! I never asked to be 'Spoon Fed'
Sterling Isfine, thank you that code worked perfectly. I'm going to try and break it apart to learn from it wherever possible.
Bookmarks