skip to content »

centr-geoteh.ru

Javascript code for validating name

javascript code for validating name-84

Java Script provides a way to validate form's data on the client's computer before sending it to the web server. First let us see how to do a basic form validation.

We will create Java Script functions (one for each input field whose value is to validate) which check whether a value submitted by user passes the validation.I have written the following Java Script code and want to ask if it is written as per best practices.Please recommend any changes to be made in the code.Here is the HTML form: Basically, when the user clicks on the submit button the browser is expecting some return value from the check Whole Form() function.The word 'this' is referring to the form as it's an object. Notice There is a span section beside the username's input field.When the user does so, they may proceed and can supply value to the next available field.

The later Java Script function created is called on the onsubmit event of the form. If Male or Female is selected, it generates an alert saying that the form is successfully submitted and it reloads the form.

All this is saying is that all properties within the curly brackets will use the 'the Form' object.

In other words, this 'username' is the property of 'the Form' object.

Can you please also help me out to calculate the complexity of the code o(n)?

I believe complexity is also very important and making it low is considered as a good practice.

If the data entered by a client was incorrect or was simply missing, the server would have to send all the data back to the client and request that the form be resubmitted with correct information.