javascript validate form by separate by comma
Use variable with javascript inner HTML
var str = document.getElementById("elementID").value
var res = str.split(" ")
res.length
Script javascript
<script type="text/javascript">
function valicontact() {
var x = document.getElementById("inputFirstname").value;
var res = x.split(",")
var y = document.getElementById("signum").value;
var ress = y.split(",")
var z = document.getElementById("Contactno").value;
var resss = z.split(",")
var n = res.length
var s = ress.length
var c = resss.length
if (s == c && s == n){
Sbutton.style.display = "block";
document.getElementById("errormessage").innerHTML = ""
} else {
document.getElementById("errormessage").innerHTML = "Number of Name,Signum and Contact should be same <br> name =" + n + "<br> Signum = " + s + "<br> Contact =" +c;
Sbutton.style.display = "none";
}
}
</script>
Comments
Post a Comment