﻿// JScript 檔
function City(source, args){
    var e = document.getElementById("DropDownListCity");
    args.IsValid=(e.selectedIndex > 0);
}

function County(source, args){
    var e = document.getElementById("DropDownListCounty");
    if(trimTxt(e.options[e.selectedIndex].value)=="" || trimTxt(e.options[e.selectedIndex].value)=="請選擇"){
        args.IsValid = false;
    }else{
        args.IsValid = true;
    }
}

function Sex(source, args){
    var e = document.getElementById("DropDownListSex");
    args.IsValid=(e.selectedIndex > 0);
}

function Edu(source, args){
    var e = document.getElementById("DropDownListEdu");
    args.IsValid=(e.selectedIndex > 0);
}

function inCome(source, args){
    var e = document.getElementById("DropDownListIncome");
    args.IsValid=(e.selectedIndex > 0);
}

function trimTxt(inText){
	myFirst = new RegExp(/^(\s)+/);
	myLast = new RegExp(/(\s)+$/);
	
	while(myFirst.test(inText) && inText.length > 0){
		inText = inText.replace(/^(\s)+/, "");
	}
	
	while(myLast.test(inText) && inText.length > 0){
		inText = inText.replace(/(\s)+$/, "");
	}

	return inText;
}

