so , here this is button type, then only I could use onclick, but I want to know if this was a text box, how could I use onclick here? please help me.The same situation I am facing , but the difference is my case is all text boxex are input text boxes, so how can I use in that case?
Using JQuery would make it much easier I think.
sarojni agrwal wrote:so how can I put onclick on that input textbox?
The real question is: Why don't you want a visible submit control? Users can submit an HTML form simply by pressing "Enter" while the focus is inside a text input field (not in a textarea) without ever clicking on the submit control. More code is needed once you remove the submit element from the form - i.e. an event handler would have to monitor key presses to intercept "Enter" and coordinate the submit programmatically (which won't necessarily work for tablets anyway).
If absolutely necessary, "hide" the submit control and leave most of the work to the browser:
HTML forms guide - Web developer guides | MDN
submit - Event reference | MDN
html - Submitting a form by pressing enter without a submit button - Stack Overflow
this is my code, in which I want to check the numbers in debit card and other fields also, but I am able to check only one, because, in input field onclick function is not used, if there are buttons rather than text boxes then I will handle, by put onclick on every button , but how can I handle here by input text texts?
if only this means only one then I will handle like this:
sarojni agrwal wrote:in which I want to check the numbers in debit card and other fields also, but I am able to check only one, because, in input field onclick function is not used, if there are buttons rather than text boxes then I will handle, by put onclick on every button , but how can I handle here by input text texts?
What makes you think that you need a separate event listener for each input text field? When the user clicks the submit button an event listener on the form element will fire. event.target will be form element and you can easily get a hold of each of the form's input fields inside the listener and retrieve their values for validation.
In the above code I got the value of the "search" text input element. If there were more text input elements I could get their values in exactly the same manner - no need for separate event listeners.
Note that the code in the example uses this while the code above above uses event.target inside the event handler. There is a subtle difference between the two: