Hi
In below code i want Child Name should accept only Alphabets , space , spacebar & .
Code
#
Lead Number
Lead Date
Name
Mobile No
Child Name
Child Age
' />
" runat="server">
'>
'>
'>
'>
'>
'>Thanks

Amit MohantyRank #112 · 20K reputationPosted May 26, 2023, 9:36 AM EDT
Try this
// Add an event listener to the form's submit event document.querySelector("#yourFormId").addEventListener("submit", function(event) { var childNameInput = document.querySelector("#txtChildName"); // Use a regular expression to match the allowed characters var pattern = /^[A-Za-z .]+$/; // Check if the input value matches the pattern if (!pattern.test(childNameInput.value)) { // Prevent form submission event.preventDefault(); // Display an error message or perform any desired action alert("Child Name should only contain alphabets, spaces, and dots."); } });