Convert DhcpInfo.dns into a readable IP
DhcpInfo.dns1 and DhcpInfo.dns2 is an integer, not a readable IP string,"x.x.x.x". That is hard to understand. I did a search in internet. There are a number of people to write their own function to do that. Actually, Android SDK has a formatter to do that.
Code
Formatter.formatIpAddress(info.dns1) |
Custom Error Message for jQuery validation
I found the jQuery validation is very good! Moreover, that is very easy to customize the error message. You just need to put the message in the "title" attribute.
e.g.
Code
<input title="Please enter your name" class="required" id="name" name="name" type="text" > |
Android Layout XML File is case-sensitive!
In the most situation, XML file is case-insensitive. I thought that is the same case as Android Layout XML. There is no different between
The Easiest Form Validation - JQuery Validation
I tried to use JQuery Validation. That is the easiest form validation library!!!!!
I just need to include the jquery library and its js file. Then I add these code in $(document).ready
Code
$([form element]).validate({rules: { | |
[field name]: { | |
[built-in Validation methods] | |
... | |
} | |
} | |
}); |
This is the validation rule.
I think that is easier to explain in an example.
I got a form like this:
Code
<form id="frm" method="POST"> | |
Name : <input type="text" id="name" name="name" /> <br/> | |
Email: <input type="text" id="email" name="email" /> | |
<input type="submit" id="submit" value="Submit"/> | |
</form> |
Then I just need add those code in $(document).ready
Code
$("#frm").validate({rules: { | |
email: { | |
required: true, | |
email: true | |
}, | |
name: "required" | |
} | |
}); |
Then the form will be validated when the user submits the data.
Android - On Screen Notification
In the C# Wolrd, we always use "MessageBox.Show (String)" to generate on screen notification (Pop-Up Message Box). In the Android, it has a similar thing calls toast. That is a small square box on the screen. Well, this is not just a single line of code, like Toast.Show(string). But that is just a few lines of codes more.
Code
Context context = getApplicationContext(); | |
CharSequence msgText= "Test"; | |
Toast toast = Toast.makeText(context,msgText, Toast.LENGTH_LONG); | |
toast.show(); |