Jump to content

inbox required field


Recommended Posts

does any one know how i would make the two below input boxes required. if the end user would leave it blank i would like for it to bring up a message stating that they need to enter in the info. thanks for your help. below is the code and the two inboxes are:

$Input1 & $Input2

#include <GUIConstants.au3>

$Form1 = GUICreate("Asset Info", 304, 210, 213, 133)
$Group1 = GUICtrlCreateGroup("Information", 16, 16, 265, 153)
$Label1 = GUICtrlCreateLabel("Username:", 32, 40, 55, 17)
$Input1 = GUICtrlCreateInput("", 88, 40, 177, 21)
$Label2 = GUICtrlCreateLabel("Hardware Type:", 32, 72, 80, 17)
$Combo1 = GUICtrlCreateCombo("", 120, 72, 145, 25, $CBS_DROPDOWNLIST)
          GUICtrlSetData(-1,"Desktop|Laptop", "")
$Label3 = GUICtrlCreateLabel("Make:", 32, 104, 34, 17)
$Combo2 = GUICtrlCreateCombo("", 72, 104, 65, 25, $CBS_DROPDOWNLIST)
          GUICtrlSetData(-1,"", "")
$Label4 = GUICtrlCreateLabel("Model:", 144, 104, 36, 17)
$Combo3 = GUICtrlCreateCombo("", 184, 104, 81, 25, $CBS_DROPDOWNLIST)
          GUICtrlSetData(-1,"", "")
$Label5 = GUICtrlCreateLabel("Asset:", 32, 136, 33, 17)
$Input2 = GUICtrlCreateInput("", 72, 136, 193, 21)
          GUICtrlCreateGroup("", -99, -99, 1, 1)
$GO = GUICtrlCreateButton("Submit", 104, 176, 75, 25, 0)
      GUISetState()

While 1
  $nMsg = GUIGetMsg()

  Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit


Case $Combo1
        If GUICtrlRead($Combo1) = "Desktop" Then
           GUICtrlSetData($Combo2, "", "")
           GUICtrlSetData($Combo3, "", "")
           GUICtrlSetData($Combo2, "Dell","")
           
        ElseIF GUICtrlRead($Combo1) = "Laptop" Then
               GUICtrlSetData($Combo2, "", "")
               GUICtrlSetData($Combo3, "", "")
               GUICtrlSetData($Combo2, "Dell|IBM","") 
        EndIf

Case $Combo2

        If GUICtrlRead($Combo2) = "Dell" AND GUICtrlRead($Combo1) = "Desktop" Then
           GUICTrlSetData($Combo3, "GX280|GX280|GX520|GX745")

        ElseIF GUICtrlRead($Combo2) = "IBM" AND GUICtrlRead($Combo1) = "Laptop" Then
               GUICtrlSetData($Combo3, "", "")
               GUICtrlSetData($Combo3, "T42|T43")

        ElseIF GUICtrlRead($Combo2) = "Dell" AND GUICtrlRead($Combo1) = "Laptop" Then
               GUICtrlSetData($Combo3, "", "")
               GUICtrlSetData($Combo3, "D600|D610|D620")

        EndIf
    EndSwitch
WEnd
Edited by surreal
Link to comment
Share on other sites

Under Case $Go (which you didn't bother to provide), just check it with:

Case $Go
          If StringStripWS(GuiCtrlRead($input1), 8) = "" Or StringStripWS(GuiCtrlRead($input2), 8) = "" Then
               MsgBox(16, "BZZZZZt!", "Error:  You didn't fill in something!")
               ContinueLoop
          EndIf

          ; Do regular $Go stuff...

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

does any one know how i would make the two below input boxes required. if the end user would leave it blank i would like for it to bring up a message stating that they need to enter in the info. thanks for your help. below is the code and the two inboxes are:

$Input1 & $Input2

#include <GUIConstants.au3>

$Form1 = GUICreate("Asset Info", 304, 210, 213, 133)
$Group1 = GUICtrlCreateGroup("Information", 16, 16, 265, 153)
$Label1 = GUICtrlCreateLabel("Username:", 32, 40, 55, 17)
$Input1 = GUICtrlCreateInput("", 88, 40, 177, 21)
$Label2 = GUICtrlCreateLabel("Hardware Type:", 32, 72, 80, 17)
$Combo1 = GUICtrlCreateCombo("", 120, 72, 145, 25, $CBS_DROPDOWNLIST)
          GUICtrlSetData(-1,"Desktop|Laptop", "")
$Label3 = GUICtrlCreateLabel("Make:", 32, 104, 34, 17)
$Combo2 = GUICtrlCreateCombo("", 72, 104, 65, 25, $CBS_DROPDOWNLIST)
          GUICtrlSetData(-1,"", "")
$Label4 = GUICtrlCreateLabel("Model:", 144, 104, 36, 17)
$Combo3 = GUICtrlCreateCombo("", 184, 104, 81, 25, $CBS_DROPDOWNLIST)
          GUICtrlSetData(-1,"", "")
$Label5 = GUICtrlCreateLabel("Asset:", 32, 136, 33, 17)
$Input2 = GUICtrlCreateInput("", 72, 136, 193, 21)
          GUICtrlCreateGroup("", -99, -99, 1, 1)
$GO = GUICtrlCreateButton("Submit", 104, 176, 75, 25, 0)
      GUISetState()

While 1
  $nMsg = GUIGetMsg()

  Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
Case $Combo1
        If GUICtrlRead($Combo1) = "Desktop" Then
           GUICtrlSetData($Combo2, "", "")
           GUICtrlSetData($Combo3, "", "")
           GUICtrlSetData($Combo2, "Dell","")
           
        ElseIF GUICtrlRead($Combo1) = "Laptop" Then
               GUICtrlSetData($Combo2, "", "")
               GUICtrlSetData($Combo3, "", "")
               GUICtrlSetData($Combo2, "Dell|IBM","") 
        EndIf

Case $Combo2

        If GUICtrlRead($Combo2) = "Dell" AND GUICtrlRead($Combo1) = "Desktop" Then
           GUICTrlSetData($Combo3, "GX280|GX280|GX520|GX745")

        ElseIF GUICtrlRead($Combo2) = "IBM" AND GUICtrlRead($Combo1) = "Laptop" Then
               GUICtrlSetData($Combo3, "", "")
               GUICtrlSetData($Combo3, "T42|T43")

        ElseIF GUICtrlRead($Combo2) = "Dell" AND GUICtrlRead($Combo1) = "Laptop" Then
               GUICtrlSetData($Combo3, "", "")
               GUICtrlSetData($Combo3, "D600|D610|D620")

        EndIf
    EndSwitch
WEnd

#include <GUIConstants.au3>

$Form1 = GUICreate("Asset Info", 304, 210, 213, 133)
$Group1 = GUICtrlCreateGroup("Information", 16, 16, 265, 153)
$Label1 = GUICtrlCreateLabel("Username:", 32, 40, 55, 17)
$Input1 = GUICtrlCreateInput("", 88, 40, 177, 21)
$Label2 = GUICtrlCreateLabel("Hardware Type:", 32, 72, 80, 17)
$Combo1 = GUICtrlCreateCombo("", 120, 72, 145, 25, $CBS_DROPDOWNLIST)
$default = "Choose."
          GUICtrlSetData(-1,"Desktop|Laptop|Choose.", $default)
$Label3 = GUICtrlCreateLabel("Make:", 32, 104, 34, 17)
$Combo2 = GUICtrlCreateCombo("", 72, 104, 65, 25, $CBS_DROPDOWNLIST)
$default = " "
          GUICtrlSetData(-1," ", $default)
$Label4 = GUICtrlCreateLabel("Model:", 144, 104, 36, 17)
$Combo3 = GUICtrlCreateCombo("", 184, 104, 81, 25, $CBS_DROPDOWNLIST)
$default = " "
          GUICtrlSetData(-1," ", $default)
$Label5 = GUICtrlCreateLabel("Asset:", 32, 136, 33, 17)
$Input2 = GUICtrlCreateInput("", 72, 136, 193, 21)
          GUICtrlCreateGroup("", -99, -99, 1, 1)
$GO = GUICtrlCreateButton("Submit", 104, 176, 75, 25, 0)
      GUISetState()

While 1
  $nMsg = GUIGetMsg()

  Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit


Case $Combo1
        If GUICtrlRead($Combo1) = "Desktop" Then
               $default1 = " "
               $default2 = "Choose."
            GUICtrlSetData($Combo3,"" ,"")
            GUICtrlSetData($Combo2,"" ,"")
           GUICtrlSetData($Combo3, " ", $default1)
           GUICtrlSetData($Combo2, "Dell|Choose.",$default2)
           
        ElseIF GUICtrlRead($Combo1) = "Laptop" Then
               $default1 = " "
               $default2 = "Choose."
               GUICtrlSetData($Combo3,"" ,"")
               GUICtrlSetData($Combo2,"" ,"")
               GUICtrlSetData($Combo3, " ", $default1)
               GUICtrlSetData($Combo2, "Dell|IBM|Choose.",$default2) 
        EndIf

Case $Combo2

        If GUICtrlRead($Combo2) = "Dell" AND GUICtrlRead($Combo1) = "Desktop" Then
           $default = "Choose."
           GUICtrlSetData($Combo3,"" ,"")
           GUICTrlSetData($Combo3, "GX280|GX280|GX520|GX745|Choose.",$default)

        ElseIF GUICtrlRead($Combo2) = "IBM" AND GUICtrlRead($Combo1) = "Laptop" Then
            $default = "Choose."
            GUICtrlSetData($Combo3,"" ,"")
            GUICtrlSetData($Combo3, "T42|T43|Choose.", $default)

        ElseIF GUICtrlRead($Combo2) = "Dell" AND GUICtrlRead($Combo1) = "Laptop" Then
            $default = "Choose."
            GUICtrlSetData($Combo3,"" ,"")
            GUICtrlSetData($Combo3, "D600|D610|D620|Choose." ,$default)

        EndIf
    EndSwitch
WEnd

صرح السماء كان هنا

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...