How to write function for multiple textboxes in Javascript

mevyIndenna

New Member
I am writing code for validating the money value as \[code\] function monyValid() { var valw=document.getElementById("<%=txtID4.ClientID%>").value; var regex = /(?:^\d{1,3}(?:\.?\d{2})*(?:,\d{2})?$)|(?:^\d{1,3}(?:,?\d{3})*(?:\.\d{2})?$)/ if (!isNaN(valw) && isFinite(valw)) { document.getElementById("<%=txtID4.ClientID%>").value=http://stackoverflow.com/questions/15700021/parseFloat(valw).toFixed(2); } if (regex.test(valw)) { alert("valid"); } else { alert("Number is invalid"); } }\[/code\]now I want to apply the same validation to multiple textboxes. How can I use the same function for different textboxes. I want something like \[code\] function monyValid(txtVal) { var valw=document.getElementById(txtVal).value; }\[/code\]How can I implement this function.
 
Back
Top