Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .idea/.name

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/JavascriptFormValidator.iml

This file was deleted.

3 changes: 0 additions & 3 deletions .idea/copyright/profiles_settings.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/encodings.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/jsLibraryMappings.xml

This file was deleted.

16 changes: 0 additions & 16 deletions .idea/misc.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

4 changes: 0 additions & 4 deletions .idea/watcherTasks.xml

This file was deleted.

20 changes: 12 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,20 @@
Then Integrate your form with Validator.

<script>

/.../

var data = {
form: 'new_ticket_form', // Required.
warning_color: 'aa0000', // Optional.
new_class: 'test' // Optional.
form: 'new_ticket_form', // Required.
warning_color: 'aa0000', // Optional.
new_class: 'test' // Optional.
};

// Validation Will Init Here.
validate(data);

/.../

</script>


Expand All @@ -44,7 +48,7 @@ It has automated listener to eliminating unnecessary changes on form.

2. Input Fields should specify the type of validation.

//***************For General Input Validation**************************************
////////////////////For General Input Validation////////////////////////////////////////

// For Simple Require.
<input type="text" required name="name">
Expand All @@ -61,17 +65,17 @@ It has automated listener to eliminating unnecessary changes on form.
// For Password Match Validation.
<input type="password" required match="field_name" name="password">

//***************For Select Validation*******************************************
////////////////////For Select Validation////////////////////////////////////////////

//For Simple Required
<select class="" required>
<option value=0></option> // This Option going to filter.
<option value="-"></option> // Value '-' is used to represent empty.
<option value="...">...</option>
<option value="...">...</option>
<option value="...">...</option>
</select>

//***************For Textarea Validation*******************************************
////////////////////For Textarea Validation//////////////////////////////////////////

// For Simple Required
<textarea required>.....</textarea>
Expand Down Expand Up @@ -111,7 +115,7 @@ So **No Need** to use ``<input type="submit"..... onClick="validate()" .....>``
display: inline !important;
}

###License
### License

MIT License

Expand Down
7 changes: 6 additions & 1 deletion src/js/formValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@ var form = {
// TODO: Simplify the "TextArea" Validation.
validate: function (form) {

// For Basic Element Selection.
var form_el = document.getElementById(form);
// For Normal Textboxes.
var st_form_inputs = form_el.getElementsByTagName('input');
// For Textareas.
var st_form_textArea = form_el.getElementsByTagName('textarea');
// For Select or Drop Down Box.
var st_form_select = form_el.getElementsByTagName('select');
// For Labels.
var st_form_labels = form_el.getElementsByTagName('label');

console.log(st_form_inputs);
Expand Down Expand Up @@ -173,7 +178,7 @@ var form = {


// Basic Field Empty Validation.
if (field_value == 0) {
if (field_value == '-') {

response = label_core + ' <span style="color: ' + warning_font_color + '; font-weight: 400" class="alert_message ' + warning_class + '">'
+ 'Choose valid Option </span>';
Expand Down