JavaScript Questions & Answers – Validation

«
»

This set of Javascript Multiple Choice Questions & Answers (MCQs) focuses on “Validation”.

1. In which part does the form validation occur?
a) Client
b) Server
c) Both Client and Server
d) User side
View Answer

Answer: b
Explanation: The data information from the client side is first sent to the server side. Form validation used to occur at the server after the client had entered all necessary data and then pressed the Submit button.
advertisement

2. What would happen if the data in the client had been wrong?
a) Sends back the data
b) Waits for correction
c) Sends back the data and Waits for correction
d) Returns the data instantly
View Answer

Answer: c
Explanation: The only way to obtain data is from the server side which is used to perform further operations on the data. If some of the data that had been entered by the client had been in the wrong form or was simply missing, the server would have to send all the data back to the client and request that the form is resubmitted with correct information.

3. What is the purpose of the basic validation?
a) Data correctness
b) Mere data existence
c) Both Data correctness and Mere data existence
d) Data modification
View Answer

Answer: b
Explanation: The data entered through the server side is used for validation. First of all, the form must be checked to make sure data was entered into each form field that required it. This would need just loop through each field in the form and check for data.
Note: Join free Sanfoundry classes at Telegram or Youtube
advertisement
advertisement

4. What is the purpose of data format validation?
a) Data correctness
b) Mere data existence
c) Both Data correctness and Mere data existence
d) Data modification
View Answer

Answer: a
Explanation: The data entered through the server side is used for validation. The data that is entered must be checked for correct form and value. This would need to put more logic to test the correctness of data.

5. Which is the function that is called to validate a data?
a) validate()
b) valid()
c) validation()
d) no predefined function for data validation
View Answer

Answer: d
Explanation: There is no such function to validate a data but, you can write a function with any name to validate the data. Hence there is no predefined function for data validation.
Take JavaScript Practice Tests - Chapterwise!
Start the Test Now: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
advertisement

6. How to find the index of a particular string?
a) position()
b) index()
c) indexOf()
d) positionof()
View Answer

Answer: c
Explanation: The indexOf() function can be used to find out the index of a particular character or a string. This method return an integer telling the address of the particular character.

7. How do you focus a particular part of the HTML page in JavaScript?
a) hover()
b) focus()
c) on()
d) focuson()
View Answer

Answer: b
Explanation: The focus() function can be used to focus a particular part of the HTML page in JavaScript. It sets the element as the active element in the current document. It can be applied to one html element at a single time in a current document.
advertisement

8. Which of the following is the child object of the JavaScript navigator?
a) Navicat
b) Plugins
c) NetRight
d) Plugs
View Answer

Answer: b
Explanation: The JavaScript navigator object is used for browser detection. The JavaScript navigator object includes a child object called plugins.

9. Which of the following is not the properties of a plug-in entry?
a) name
b) filename
c) mimeTypes
d) value
View Answer

Answer: d
Explanation: Plugins are reusable portions of code which help you write even less Javascript to achieve specific features on the client side. Each plug-in has an entry in the array. Each entry has the following properties:

  • name – is the name of the plug-in.
  • filename – is the executable file that was loaded to install the plug-in.
  • description – is a description of the plug-in, supplied by the developer.
  • mimeTypes – is an array with one entry for each MIME type supported by the plug-in.
advertisement

10. What is the purpose of the mimeTypes property of a plug-in entry?
a) Contains MIME properties
b) Contains MIME sizes
c) Contains MIME types
d) Contains MIME methods
View Answer

Answer: c
Explanation: MIME stands for Multi-purpose Internet Mail Extensions. mimeTypes is an array with one entry for each MIME type supported by the plug-in.

Sanfoundry Global Education & Learning Series – Javascript Programming.

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & technical discussions at Telegram SanfoundryClasses.