Hi
I have below code . I want ChildName should accept only Alphabets , Spaces , Backspace & .
Child Age should accept onlt 1-100 values. Message should appear in modal popup
Code
' />
" runat="server">
'>
' >
' >
--%>Thanks

Amit MohantyRank #112 · 20K reputationPosted May 31, 2023, 1:39 AM EDT
Try this:
' /> " runat="server"> '> '> '> tag --> Validation Error Close function showModalPopup(message) { // Set the error message in the modal popup document.getElementById('').innerText = message; // Show the modal popup $('#myModal').modal('show'); } function validateFields() { var childName = document.getElementById('').value; var childAge = document.getElementById('').value; // ChildName validation var childNameRegex = /^[a-zA-Z.\s]*$/; if (!childNameRegex.test(childName)) { showModalPopup("Child Name should only contain alphabets, spaces, and dots (.)"); return false; } // ChildAge validation if (isNaN(childAge) || childAge 100) { showModalPopup("Age should be between 1 and 100."); return false; } return true; } // Attach the validation function to the form submission event document.getElementById('').onsubmit = function() { return validateFields(); };