函數sub()
var userName = document . getelementbyid('用戶名')。價值;
if(userName = = ' '){ alert(' userName不能為空');返回false}else返回true
& ltscript/& gt;
& ltform method = " post " id = " form 1 " name = " form 1 " action = ' log in . action ' on submit = " return sub();"& gt& ltinput type = " text " name = " userName " id = " userName "/& gt;& lt/form & gt;