<html>
<head>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" >
var fields = {
userName: false,
phoneNumber: false,
userEmail: false
};
var f = function(){
switch (this.id) {
case 'userName':
fields[this.id] = this.value.match(/[\s\w]+/) ? true : false;
break;
case 'phoneNumber':
fields[this.id] = this.value.match(/[\d]+/) ? true : false;
break;
case 'userEmail':
fields[this.id] = this.value.match(/[\d\w._]+@[\d\w._]+/) ? true : false;
break;
}
var sum = 0;
for (var key in fields) {
sum += fields[key] ? 1 : 0;
}
sum === 3 && alert('message')
};
$(function(){
$('#userName').change(f);
$('#phoneNumber').change(f);
$('#userEmail').change(f);
})
</script>
</head>
<body>
<input type="text" id="userName" /><br />
<input type="text" id="phoneNumber" /><br />
<input type="text" id="userEmail" /><br />
</body>
</html>